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.
This commit is contained in:
ahocevar
2013-12-12 17:57:14 +01:00
parent d147d11b51
commit c4ec53bbdb

View File

@@ -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]);
}
};