Closed clukas1 closed 2 months ago
Thanks @clukas1, looks good.
It is a bit difficult to read the code and follow in the debugger due to passing around all the arrays.
In this commit https://github.com/naviqore/public-transit-service/commit/9236013c47853156a832da2bc3049393c3e5f5f9 on the branch feature/NAV-181-extract-marked-stops-class I extracted a MarkedStops
class to encapsulate the logic of the stop mask. In performance there is not really a difference (some ms faster):
Before:
After:
Then i tried to get rid of the array copy / new allocation in https://github.com/naviqore/public-transit-service/commit/7e69a2688a4b0709bbd09abc121bf51f669567d0, by using an int array instead boolean, tracking the rounds. But somehow the logic messes up...
Should we introduce a MarkedStops
(or other name, e.g. StopMask
) class, to track the marked stops? And possibly omit the rest on the branch...
@munterfi I've moved the logic of markedStopsMasks to the Query State because they fit in there nicely. The int array will not work, because you will sometimes overwrite a to be checked mark to the new round potentially preventing finding ideal solutions.
benchmarking the both solutions (before and after refactoring) shows following results, probably just noise holding them apart.
Thanks, looks good to merge.
Created new pull request, to allow you to review the request.
Change is that boolean[] arrays are used to mask routesToScan and markedStops instead of HashSets. Performance has been improved significantly.
Original:
With Hashset set to size of Stops/Routes
With Boolean Arrays