Skip to content

Commit

Permalink
Remove unnecessary Cow in kdtree trait
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Dec 25, 2024
1 parent 1f45cce commit d3f28dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/kdtree/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn make_index() -> OwnedKDTree<f64> {
fn creates_an_index() {
let owned_index = make_index();
let kdbush = owned_index.as_kdtree_ref();
let tree_ids = kdbush.ids().into_owned();
let tree_ids = kdbush.ids();
let tree_ids = match tree_ids {
Indices::U16(arr) => arr,
_ => unimplemented!(),
Expand Down
8 changes: 3 additions & 5 deletions src/kdtree/trait.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::borrow::Cow;

use geo_traits::{CoordTrait, RectTrait};
use tinyvec::TinyVec;

Expand All @@ -11,7 +9,7 @@ pub trait KDTreeIndex<N: IndexableNum> {
fn num_items(&self) -> usize;
fn node_size(&self) -> usize;
fn coords(&self) -> &[N];
fn ids(&self) -> Cow<'_, Indices>;
fn ids(&self) -> Indices;

/// Search the index for items within a given bounding box.
///
Expand Down Expand Up @@ -182,8 +180,8 @@ impl<N: IndexableNum> KDTreeIndex<N> for KDTreeRef<'_, N> {
self.coords
}

fn ids(&self) -> Cow<'_, Indices> {
Cow::Borrowed(&self.ids)
fn ids(&self) -> Indices {
self.ids
}
}

Expand Down

0 comments on commit d3f28dc

Please sign in to comment.