openlayers/ol3 — pull request #1997 by elemoine (2014-04-18 09:22:11+00:00)
Title: Make handling of skipped features faster

Aaron Solberg [reported](https://groups.google.com/d/msg/ol3-dev/LjHVWy3AHO0/tGjEcDsmlPgJ) 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

```js
features = vectorSource.getFeatures();
for (i = 0; i < 10000; ++i) { map.getSkippedFeatures().push(features[i]); }
```

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(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.