From 616b3bd66263396e12e0e8c895cfc6de15984a60 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 29 Mar 2015 13:05:07 -0700 Subject: [PATCH] Minor hosts to improve loop perf --- commands/run_cmd.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/run_cmd.py b/commands/run_cmd.py index 8b3cfdd4..aea503b1 100644 --- a/commands/run_cmd.py +++ b/commands/run_cmd.py @@ -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 @@ -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): @@ -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): @@ -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):