js-markerclusterer icon indicating copy to clipboard operation
js-markerclusterer copied to clipboard

[ClusterStats] compute lazily

Open vicb opened this issue 2 years ago • 0 comments

As of today the stats are computed eagerly as they are constructed:

https://github.com/googlemaps/js-markerclusterer/blob/e8eecf49b1d1f59579f3316c705f2c131b796560/src/renderer.ts#L35-L50

That's wasted CPU cycles when the stats are not required (i.e. with a custom renderer).

We should compute the stats lazily when one of the markers's property is first accessed to avoid that.

This could be done in a backward compatible way using getters.

vicb avatar May 24 '23 16:05 vicb