[Pkg-javascript-commits] [leaflet-markercluster] 49/128: Simplified _recursively

Jonas Smedegaard dr at jones.dk
Sun Apr 16 06:26:02 UTC 2017


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

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

commit 8bdb884c8884315e0b8b53d533a3e73a1293e761
Author: ghybs <ghybs1 at gmail.com>
Date:   Sat Apr 2 07:39:37 2016 +0400

    Simplified _recursively
    
    Re-visited the conditions order to avoid the 2 similar loops.
---
 src/MarkerCluster.js | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index 68747fc..8c73cac 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -370,29 +370,20 @@ L.MarkerCluster = L.Marker.extend({
 		    zoom = this._zoom,
 		    i, c;
 
-		if (zoomLevelToStart > zoom) { //Still going down to required depth, just recurse to child clusters
-			for (i = childClusters.length - 1; i >= 0; i--) {
-				c = childClusters[i];
-				if (boundsToApplyTo.intersects(c._bounds)) {
-					c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
-				}
-			}
-		} else { //In required depth
-
+		if (zoomLevelToStart <= zoom) {
 			if (runAtEveryLevel) {
 				runAtEveryLevel(this);
 			}
-			if (runAtBottomLevel && this._zoom === zoomLevelToStop) {
+			if (runAtBottomLevel && zoom === zoomLevelToStop) {
 				runAtBottomLevel(this);
 			}
+		}
 
-			//TODO: This loop is almost the same as above
-			if (zoomLevelToStop > zoom) {
-				for (i = childClusters.length - 1; i >= 0; i--) {
-					c = childClusters[i];
-					if (boundsToApplyTo.intersects(c._bounds)) {
-						c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
-					}
+		if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) {
+			for (i = childClusters.length - 1; i >= 0; i--) {
+				c = childClusters[i];
+				if (boundsToApplyTo.intersects(c._bounds)) {
+					c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
 				}
 			}
 		}

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