Skip to content

Commit

Permalink
Use unstable sort for envelopes and node reinsertion (#160)
Browse files Browse the repository at this point in the history
* Use unstable sort for envelopes and node reinsertion

* Add changelog entry
  • Loading branch information
grovesNL authored Mar 14, 2024
1 parent 5717559 commit 650a901
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions rstar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

## Changed
- Switched to unstable sort for envelopes and node reinsertion ([PR](https://github.com/georust/rstar/pull/160))

# 0.12.0

## Added
Expand Down
2 changes: 1 addition & 1 deletion rstar/src/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
}

fn sort_envelopes<T: RTreeObject<Envelope = Self>>(axis: usize, envelopes: &mut [T]) {
envelopes.sort_by(|l, r| {
envelopes.sort_unstable_by(|l, r| {
l.envelope()
.lower
.nth(axis)
Expand Down
2 changes: 1 addition & 1 deletion rstar/src/algorithm/rstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ where
{
let center = node.envelope.center();
// Sort with increasing order so we can use Vec::split_off
node.children.sort_by(|l, r| {
node.children.sort_unstable_by(|l, r| {
let l_center = l.envelope().center();
let r_center = r.envelope().center();
l_center
Expand Down

0 comments on commit 650a901

Please sign in to comment.