Skip to content

Commit

Permalink
when removing, only descend into children that can contain the node t…
Browse files Browse the repository at this point in the history
…o remove

A node's bbox is the union of its children's bboxes.  When searching for
a node with a specific extent, the node can only be in children who's
bboxes strictly contain the node's extent.  We can therefore replace the
intersection test with a stricter contains test.  This improves the
speed of remove by about 50%.
  • Loading branch information
twpayne committed Nov 25, 2013
1 parent 09b048f commit d3bf777
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rbush.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ rbush.prototype = {
}
}

if (!goingUp && !node.leaf && this._intersects(bbox, node.bbox)) { // go down
if (!goingUp && !node.leaf && this._contains(node.bbox, bbox)) { // go down
path.push(node);
indexes.push(i);
i = 0;
Expand Down

0 comments on commit d3bf777

Please sign in to comment.