Skip to content

Commit

Permalink
less
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Mar 28, 2024
1 parent f5d51ce commit 39b0832
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
4 changes: 4 additions & 0 deletions vortex-array/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ vortex-schema = { path = "../vortex-schema" }

[dev-dependencies]
criterion = { workspace = true }

[[bench]]
name = "search_sorted"
harness = false
16 changes: 2 additions & 14 deletions vortex-array/src/compute/search_sorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ impl<S: IndexOrd<T> + Len + ?Sized, T> SearchSorted<T> for S {
}
}

impl<T: Array> IndexOrd<Scalar> for T {
fn index_cmp(&self, idx: usize, elem: &Scalar) -> Option<Ordering> {
let scalar_a = scalar_at(self, idx).ok()?;
scalar_a.partial_cmp(elem)
}
}

impl IndexOrd<Scalar> for &dyn Array {
fn index_cmp(&self, idx: usize, elem: &Scalar) -> Option<Ordering> {
let scalar_a = scalar_at(*self, idx).ok()?;
Expand All @@ -131,13 +124,8 @@ impl IndexOrd<Scalar> for &dyn Array {

impl<T: PartialOrd> IndexOrd<T> for [T] {
fn index_cmp(&self, idx: usize, elem: &T) -> Option<Ordering> {
self[idx].partial_cmp(elem)
}
}

impl<T: Array> Len for T {
fn len(&self) -> usize {
T::len(self)
// SAFETY: Used in search_sorted_by same as the standard library. The search_sorted ensures idx is in bounds
unsafe { self.get_unchecked(idx) }.partial_cmp(elem)
}
}

Expand Down

0 comments on commit 39b0832

Please sign in to comment.