Skip to content

Commit

Permalink
Avoid buildingLinks/loadingTrades when we don't need it.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Oct 26, 2014
1 parent 3b78e05 commit 0d8d9d3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ def processRunArguments(args):
(finalStation and finalStation in viaStations)):
raise CommandLineError("from/to/via repeat conflicts with --unique")

tdb.loadTrades()

if originStation and originStation.itemCount == 0:
raise NoDataError("Start station {} doesn't have any price data.".format(originStation.name()))
if finalStation and finalStation.itemCount == 0:
Expand Down Expand Up @@ -738,6 +740,8 @@ def localCommand(args):
if args.ly is None: args.ly = (ship.maxLyFull if args.full else ship.maxLyEmpty)
ly = args.ly or tdb.maxSystemLinkLy

tdb.buildLinks()

printHeading("Local systems to {} within {} ly.".format(srcSystem.name(), ly))

distances = { }
Expand Down Expand Up @@ -781,6 +785,8 @@ def navCommand(args):
openList = { srcSystem: 0.0 }
distances = { srcSystem: [ 0.0, None ] }

tdb.buildLinks()

# As long as the open list is not empty, keep iterating.
while openList and not dstSystem in distances:
# Expand the search domain by one jump; grab the list of
Expand Down Expand Up @@ -1045,7 +1051,7 @@ def main():
os.chdir(str(exePath))

# load the database
tdb = TradeDB(debug=args.debug, dbFilename=args.db)
tdb = TradeDB(debug=args.debug, dbFilename=args.db, buildLinks=False, includeTrades=False)

# run the commands
commandFunction = args.proc
Expand Down

0 comments on commit 0d8d9d3

Please sign in to comment.