pioneerspacesim/pioneer — pull request #2851 by fluffyfreak (2014-04-07 17:09:14+00:00)
Title: Improve tradeships.lua

This is entirely the fault of @robn for [goading me into it](http://pioneerspacesim.net/forum/viewtopic.php?f=3&t=199&start=10#p2288) ;) very clever...

First of all I profiled to find the worst offenders and added some logging. It turns out that we were requesting some MASSIVE distances in `GetNearbySystems`. I think the largest I saw was 67.7 Light Years... that's not very NEAR in my book! I've limited it to a maximum of 30 Light years which still describes a sphere of space 60 light years across. I've also started using only the first half of the possible Hyperspace distance *IF* it's good enough.

Next I've started sorting the list of SystemPaths that are submitted as jobs to be generated/cached so that we might get the ones closest to our origin system first. Rather than those furthest away being generated first.

Finally I noticed that we seem to need some extra profile logging in `GasGiant.cpp`.

Now when I profile... `GetNearbySystems` doesn't even show up and there's very few stalls, certainly none on the order of 50 seconds like I was seeing when I started :)

Now it's time for Tea!

Andy