nebula.gl icon indicating copy to clipboard operation
nebula.gl copied to clipboard

fix isFeatureSelected performance

Open timnyborg opened this issue 3 years ago • 0 comments

isFeatureSelected() becomes a performance bottleneck when editing layers with 30,000+ features, because it's running indexOf on every single feature (so O(n^2) time, regardless of how many features are selected).

With this change, each feature is checked against the contents of the selectedFeatures list, which is O(n) if you have a single item selected, gradually taking more time as the list increases. This could probably be improved further by using a Set for selectedFeatures, but I don't know the implications of altering the structure of the layer's state.

timnyborg avatar Jul 05 '22 12:07 timnyborg