Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The biggest savings come from just calling sort less often. Instead of in the inner-most loop, we call it after processing the whole map of predecessors. The other portion is just not appending duplicate items to the queue. I do this in a simple way by maintaining a set of queued things (similar to the visited set). I think the "proper" way to fix this would be to use a sorted list for queue instead of sorting after every pass, but I'm too lazy to implement that, and I don't think it's part of the go stdlib. For our use case, on my machine, StableTopologicalSort took: Before: 230.00s After: 0.03s Signed-off-by: Jon Johnson <[email protected]>
- Loading branch information