[Pkg-javascript-commits] [leaflet-markercluster] 347/479: Remove hasProperty checks from loops. Refs leaflet/leaflet#1606

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:50 UTC 2014


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

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

commit dcbaabe23425feb295095b34e7e61add0a9a58ac
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Apr 24 10:48:00 2013 +1200

    Remove hasProperty checks from loops. Refs leaflet/leaflet#1606
---
 build/hintrc.js           |  2 +-
 src/DistanceGrid.js       | 20 ++++++++------------
 src/MarkerClusterGroup.js | 36 ++++++++++++------------------------
 3 files changed, 21 insertions(+), 37 deletions(-)

diff --git a/build/hintrc.js b/build/hintrc.js
index d05d406..ce23a0b 100644
--- a/build/hintrc.js
+++ b/build/hintrc.js
@@ -18,7 +18,7 @@ exports.config = {
 	"eqnull": false,
 	"evil": false,
 	"expr": false,
-	"forin": true,
+	"forin": false,
 	"immed": true,
 	"latedef": true,
 	"loopfunc": false,
diff --git a/src/DistanceGrid.js b/src/DistanceGrid.js
index 8235c61..5670c49 100644
--- a/src/DistanceGrid.js
+++ b/src/DistanceGrid.js
@@ -57,20 +57,16 @@ L.DistanceGrid.prototype = {
 		    grid = this._grid;
 
 		for (i in grid) {
-			if (grid.hasOwnProperty(i)) {
-				row = grid[i];
+			row = grid[i];
 
-				for (j in row) {
-					if (row.hasOwnProperty(j)) {
-						cell = row[j];
+			for (j in row) {
+				cell = row[j];
 
-						for (k = 0, len = cell.length; k < len; k++) {
-							removed = fn.call(context, cell[k]);
-							if (removed) {
-								k--;
-								len--;
-							}
-						}
+				for (k = 0, len = cell.length; k < len; k++) {
+					removed = fn.call(context, cell[k]);
+					if (removed) {
+						k--;
+						len--;
 					}
 				}
 			}
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 60c48d8..f0fd78f 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -50,9 +50,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		if (layer instanceof L.LayerGroup) {
 			var array = [];
 			for (var i in layer._layers) {
-				if (layer._layers.hasOwnProperty(i)) {
-					array.push(layer._layers[i]);
-				}
+				array.push(layer._layers[i]);
 			}
 			return this.addLayers(array);
 		}
@@ -149,11 +147,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		//Update the icons of all those visible clusters that were affected
 		for (i in this._layers) {
-			if (this._layers.hasOwnProperty(i)) {
-				m = this._layers[i];
-				if (m instanceof L.MarkerCluster && m._iconNeedsUpdate) {
-					m._updateIcon();
-				}
+			m = this._layers[i];
+			if (m instanceof L.MarkerCluster && m._iconNeedsUpdate) {
+				m._updateIcon();
 			}
 		}
 
@@ -192,11 +188,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
 
 		for (i in this._layers) {
-			if (this._layers.hasOwnProperty(i)) {
-				m = this._layers[i];
-				if (m instanceof L.MarkerCluster) {
-					m._updateIcon();
-				}
+			m = this._layers[i];
+			if (m instanceof L.MarkerCluster) {
+				m._updateIcon();
 			}
 		}
 
@@ -220,9 +214,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		//Remove all the visible layers
 		for (var i in this._layers) {
-			if (this._layers.hasOwnProperty(i)) {
-				L.FeatureGroup.prototype.removeLayer.call(this, this._layers[i]);
-			}
+			L.FeatureGroup.prototype.removeLayer.call(this, this._layers[i]);
 		}
 
 		this.eachLayer(function (marker) {
@@ -373,9 +365,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		//Clean up all the layers we added to the map
 		for (var i in this._layers) {
-			if (this._layers.hasOwnProperty(i)) {
-				L.FeatureGroup.prototype.removeLayer.call(this, this._layers[i]);
-			}
+			L.FeatureGroup.prototype.removeLayer.call(this, this._layers[i]);
 		}
 
 		this._map = null;
@@ -789,12 +779,10 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 		me._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel);
 		//TODO Maybe? Update markers in _recursivelyBecomeVisible
 		for (j in me._layers) {
-			if (me._layers.hasOwnProperty(j)) {
-				n = me._layers[j];
+			n = me._layers[j];
 
-				if (!(n instanceof L.MarkerCluster) && n._icon) {
-					n.setOpacity(1);
-				}
+			if (!(n instanceof L.MarkerCluster) && n._icon) {
+				n.setOpacity(1);
 			}
 		}
 

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