-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize algorithm by sorting in-place
This finishes the optimizations by relying on the fact that we're passing a reference to the list which means we can modify it in-place. We sort the whole list of symbols on the first pass only, and then as sort children into parents' buckets we *move* them by adding them to `parent.Children` and removing them from the current list, and then recurse and modify those lists until we're done. I don't normally like relying on side-effects such as modifying in the called function, but it makes the most sense in this case for optimizations and is duly noted.
- Loading branch information
1 parent
d8033b7
commit 993a54c
Showing
1 changed file
with
39 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters