From c4ec53bbdb6e7fe16bd2b8ff9fc12c64e1ec6472 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 12 Dec 2013 17:57:14 +0100 Subject: [PATCH] Unnest loops Reusing the iterator in a nested loop is not a good idea. And in this case it is better to not have nested loops at all, because we only have to create one array. --- src/ol/interaction/modifyinteraction.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index fdef1b88e7..4724c008fb 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -243,18 +243,18 @@ ol.interaction.Modify.prototype.addIndex_ = function(features, layer) { */ ol.interaction.Modify.prototype.removeIndex_ = function(features) { var rBush = this.rBush_; - var i, feature, nodesToRemove; + var nodesToRemove = []; + var i, feature; for (i = features.length - 1; i >= 0; --i) { feature = features[i]; - nodesToRemove = []; rBush.forEachInExtent(feature.getGeometry().getBounds(), function(node) { if (feature === node.feature) { nodesToRemove.push(node); } }); - for (i = nodesToRemove.length - 1; i >= 0; --i) { - rBush.remove(nodesToRemove[i]); - } + } + for (i = nodesToRemove.length - 1; i >= 0; --i) { + rBush.remove(nodesToRemove[i]); } };