File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,8 @@ export var MarkerClusterGroup = L.MarkerClusterGroup = L.FeatureGroup.extend({
292292
293293 process ( ) ;
294294 } else {
295- var needsClustering = this . _needsClustering ;
295+ var needsClustering = new Array ( l - offset ) ; // improve performance by preallocating the maximum size of our array
296+ var tail = 0 ;
296297
297298 for ( ; offset < l ; offset ++ ) {
298299 m = layersArray [ offset ] ;
@@ -318,8 +319,11 @@ export var MarkerClusterGroup = L.MarkerClusterGroup = L.FeatureGroup.extend({
318319 continue ;
319320 }
320321
321- needsClustering . push ( m ) ;
322+ needsClustering [ tail ++ ] = m ;
322323 }
324+
325+ needsClustering = needsClustering . slice ( 0 , tail ) ; // truncate empty elements
326+ this . _needsClustering . push . apply ( this . _needsClustering , needsClustering ) ;
323327 }
324328 return this ;
325329 } ,
You can’t perform that action at this time.
0 commit comments