Skip to content

Commit

Permalink
Minor hosts to improve loop perf
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Mar 29, 2015
1 parent 46ec99f commit 616b3bd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions commands/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ def run(results, cmdenv, tdb):
stopStations = cmdenv.destinations
goalSystem = cmdenv.goalSystem
maxLs = cmdenv.maxLs
maxHopDistLy = cmdenv.maxJumpsPer * cmdenv.maxLyPer

# seed the route table with starting places
startCr = cmdenv.credits - cmdenv.insurance
Expand All @@ -1019,6 +1020,7 @@ def run(results, cmdenv, tdb):
results.summary.exception = ""

pruneMod = cmdenv.pruneScores / 100
distancePruning = (cmdenv.destPlace or cmdenv.loop)

loopRoutes = []
for hopNo in range(numHops):
Expand All @@ -1040,8 +1042,8 @@ def run(results, cmdenv, tdb):
if cmdenv.maxRoutes and len(routes) > cmdenv.maxRoutes:
routes = routes[:cmdenv.maxRoutes]

if cmdenv.destPlace or cmdenv.loop:
remainingDistance = (numHops - hopNo) * cmdenv.maxJumpsPer * cmdenv.maxLyPer
if distancePruning:
remainingDistance = (numHops - hopNo) * maxHopDistLy
remainingDistanceSq = remainingDistance * remainingDistance

def canReachStopStation(r):
Expand All @@ -1050,7 +1052,7 @@ def canReachStopStation(r):
else:
stopSystems = {stopStation.system
for stopStation in stopStations}
reachableSystems = [stopSystem.name()
reachableSystems = [stopSystem
for stopSystem in stopSystems
if r.lastSystem.distToSq(stopSystem) <= remainingDistanceSq]
if len(reachableSystems):
Expand Down

0 comments on commit 616b3bd

Please sign in to comment.