Make handling of skipped features faster #1997
Merged
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.
Aaron Solberg reported serious performance problems occuring when adding features to the map's skippedFeatures collection.
The issue can be reproduced on the synthetic-points example:
open http://ol3js.org/en/master/examples/synthetic-points.html?mode=raw
in the console do
The code will take a long time to execute… (and the map to be refreshed)
The issue has nothing to do with the rendering code. It's related to the way we handle "add" (and "remove") events in ol.Map when features are added to the skipped features collection. Currently, each time a feature is added we clear the skippedFeatureUids_ object and re-populate with a loop over the features in the skipped features collection. So the complexity of adding N features to a skipped features collection of length M is O(M * N).
With this PR we no longer repopulate the skippedFeatureUids_ object from scratch. The complexity of adding N features to a skipped features collection is O(N). Can be tested here: http://erilem.net/ol3/skipped-features-performance/examples/synthetic-points.html?mode=raw.