Remove hasProperty checks from loops. Refs leaflet/leaflet#1606

This commit is contained in:
danzel
2013-04-24 10:48:00 +12:00
parent 890406abd6
commit dcbaabe234
3 changed files with 21 additions and 37 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ exports.config = {
"eqnull": false,
"evil": false,
"expr": false,
"forin": true,
"forin": false,
"immed": true,
"latedef": true,
"loopfunc": false,
+8 -12
View File
@@ -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--;
}
}
}
+12 -24
View File
@@ -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);
}
}