Change outlineItem ID assignment process for major optimization #827
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This code uses an O(1) process to assign IDs (keep track of the largest ID that has been assigned, and make sure to assign an ID larger than that), compared to the existing O(n^2) process (get a list of all existing IDs, and check every candidate ID starting from 1 until finding one not in the list).
My testing has shown that currently, of all the time spent reading from file, parsing, and setting data, 99.7% of it is spent in the findUniqueID() method. Making this change has led to a speedup from ~18 sec. to ~2 sec on loading my manuscript, while still guaranteeing that any (new) objects have unique IDs.