Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/MarkerClusterGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ export var MarkerClusterGroup = L.MarkerClusterGroup = L.FeatureGroup.extend({

process();
} else {
var needsClustering = this._needsClustering;
var needsClustering = new Array(l - offset); // improve performance by preallocating the maximum size of our array
var tail = 0;

for (; offset < l; offset++) {
m = layersArray[offset];
Expand All @@ -318,8 +319,11 @@ export var MarkerClusterGroup = L.MarkerClusterGroup = L.FeatureGroup.extend({
continue;
}

needsClustering.push(m);
needsClustering[tail++] = m;
}

needsClustering = needsClustering.slice(0, tail); // truncate empty elements
this._needsClustering = this._needsClustering.concat(needsClustering);
}
return this;
},
Expand Down