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:
@@ -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]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user