[Pkg-javascript-commits] [leaflet-markercluster] 05/219: Fix up a performance issue found, when adding markers we were doing a lot of unnecessary checks for duplicate markers.

Jonas Smedegaard dr at jones.dk
Sat May 7 09:39:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit e102ec0c968d19616827795aff5feb4dcca090ec
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Dec 20 10:02:29 2013 +1300

    Fix up a performance issue found, when adding markers we were doing a lot of unnecessary checks for duplicate markers.
---
 src/MarkerClusterGroup.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 42564d2..9fed1f9 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -160,7 +160,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		var fg = this._featureGroup,
 			npg = this._nonPointGroup,
 			chunkSize = this.options.chunkSize,
-			i, l, m;
+			newMarkers, i, l, m;
 
 		if (this._map) {
 			var start = 0;
@@ -206,13 +206,14 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 					start = end;
 					end = Math.min(end + chunkSize, layersArray.length);
 					console.log((+new Date()) + ' queueing ' + start + ' - ' + end);
-					setTimeout(process, 100);
+					setTimeout(process, 0);
 				}
 			}, this);
 
 			process();
 		} else {
 			console.log((+new Date()) + ' start pre-add');
+			newMarkers = [];
 			for (i = 0, l = layersArray.length; i < l; i++) {
 				m = layersArray[i];
 
@@ -226,8 +227,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 					continue;
 				}
 
-				this._needsClustering.push(m);
+				newMarkers.push(m);
 			}
+			this._needsClustering = this._needsClustering.concat(newMarkers);
 			console.log((+new Date()) + ' end pre-add');
 		}
 		return this;
@@ -639,7 +641,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			e.layer.zoomToBounds();
 		}
 
-    // Focus the map again for keyboard users.
+		// Focus the map again for keyboard users.
 		if (e.originalEvent && e.originalEvent.keyCode === 13) {
 			map._container.focus();
 		}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git



More information about the Pkg-javascript-commits mailing list