diff --git a/vortex-array/src/array/erased.rs b/vortex-array/src/array/erased.rs index 77800377f1c..4543390b073 100644 --- a/vortex-array/src/array/erased.rs +++ b/vortex-array/src/array/erased.rs @@ -390,16 +390,19 @@ impl ArrayRef { } /// Does the array match the given matcher. + #[inline] pub fn is(&self) -> bool { M::matches(self) } /// Returns the array downcast by the given matcher. + #[inline] pub fn as_(&self) -> M::Match<'_> { self.as_opt::().vortex_expect("Failed to downcast") } /// Returns the array downcast by the given matcher. + #[inline] pub fn as_opt(&self) -> Option> { M::try_match(self) } @@ -738,10 +741,12 @@ impl IntoArray for ArrayRef { impl Matcher for V { type Match<'a> = ArrayView<'a, V>; + #[inline] fn matches(array: &ArrayRef) -> bool { array.0.data.as_any().is::>() } + #[inline] fn try_match(array: &'_ ArrayRef) -> Option> { let inner = array.0.data.as_any().downcast_ref::>()?; // # Safety checked by `downcast_ref`. diff --git a/vortex-array/src/arrays/varbinview/compute/zip.rs b/vortex-array/src/arrays/varbinview/compute/zip.rs index f4a5c26a9ce..9c198fe6f2c 100644 --- a/vortex-array/src/arrays/varbinview/compute/zip.rs +++ b/vortex-array/src/arrays/varbinview/compute/zip.rs @@ -177,6 +177,7 @@ fn push_range( } } +#[inline] fn push_view( view: BinaryView, buffer_lookup: &[u32], diff --git a/vortex-array/src/buffer.rs b/vortex-array/src/buffer.rs index 29f9d3582be..faf7874b6ca 100644 --- a/vortex-array/src/buffer.rs +++ b/vortex-array/src/buffer.rs @@ -249,6 +249,7 @@ impl BufferHandle { } /// Downcast this handle as a handle to a host-resident buffer, or `None`. + #[inline] pub fn as_host_opt(&self) -> Option<&ByteBuffer> { match &self.0 { Inner::Host(buffer) => Some(buffer), @@ -266,6 +267,7 @@ impl BufferHandle { /// A version of [`as_host_opt`][Self::as_host_opt] that panics if the allocation is /// not a host allocation. + #[inline] pub fn as_host(&self) -> &ByteBuffer { self.as_host_opt().vortex_expect("expected host buffer") } diff --git a/vortex-array/src/builders/varbinview.rs b/vortex-array/src/builders/varbinview.rs index e06b54dd78c..392bef59997 100644 --- a/vortex-array/src/builders/varbinview.rs +++ b/vortex-array/src/builders/varbinview.rs @@ -367,6 +367,7 @@ impl ArrayBuilder for VarBinViewBuilder { } impl VarBinViewBuilder { + #[inline] fn push_view( &mut self, view: BinaryView, @@ -758,6 +759,7 @@ enum PrecomputedViewAdjustment { } impl PrecomputedViewAdjustment { + #[inline] fn adjust_view(&self, view: &BinaryView) -> BinaryView { if view.is_inlined() { return *view; @@ -815,6 +817,7 @@ struct RewritingViewAdjustment { impl RewritingViewAdjustment { /// Can return None if this view can't be adjusted, because there is no precomputed lookup /// for the current buffer. + #[inline] fn adjust_view(&self, view: &BinaryView) -> Option { if view.is_inlined() { return Some(*view); diff --git a/vortex-array/src/canonical.rs b/vortex-array/src/canonical.rs index 6fbdc154a6c..28589ec8c20 100644 --- a/vortex-array/src/canonical.rs +++ b/vortex-array/src/canonical.rs @@ -1072,6 +1072,7 @@ pub struct AnyCanonical; impl Matcher for AnyCanonical { type Match<'a> = CanonicalView<'a>; + #[inline] fn matches(array: &ArrayRef) -> bool { array.is::() || array.is::() @@ -1085,6 +1086,7 @@ impl Matcher for AnyCanonical { || array.is::() } + #[inline] fn try_match(array: &ArrayRef) -> Option> { if let Some(a) = array.as_opt::() { Some(CanonicalView::Null(a)) diff --git a/vortex-array/src/matcher.rs b/vortex-array/src/matcher.rs index 532931df083..c3f9e542f13 100644 --- a/vortex-array/src/matcher.rs +++ b/vortex-array/src/matcher.rs @@ -8,6 +8,7 @@ pub trait Matcher { type Match<'a>; /// Check if the given array matches this matcher type + #[inline] fn matches(array: &ArrayRef) -> bool { Self::try_match(array).is_some() } diff --git a/vortex-array/src/search_sorted.rs b/vortex-array/src/search_sorted.rs index f3514708aec..3db5215e049 100644 --- a/vortex-array/src/search_sorted.rs +++ b/vortex-array/src/search_sorted.rs @@ -103,10 +103,12 @@ pub trait IndexOrd { /// For example, if self\[idx\] > elem, return Some(Greater). fn index_cmp(&self, idx: usize, elem: &V) -> VortexResult>; + #[inline] fn index_lt(&self, idx: usize, elem: &V) -> VortexResult { Ok(matches!(self.index_cmp(idx, elem)?, Some(Less))) } + #[inline] fn index_le(&self, idx: usize, elem: &V) -> VortexResult { Ok(matches!(self.index_cmp(idx, elem)?, Some(Less | Equal))) } @@ -132,6 +134,7 @@ pub trait IndexOrd { /// |left |array\[i-1\] < value <= array\[i\]| /// |right|array\[i-1\] <= value < array\[i\]| pub trait SearchSorted { + #[inline] fn search_sorted(&self, value: &T, side: SearchSortedSide) -> VortexResult where Self: IndexOrd, @@ -180,6 +183,7 @@ impl SearchSorted for S where S: IndexOrd + ?Sized, { + #[inline] fn search_sorted_by< F: FnMut(usize) -> VortexResult, N: FnMut(usize) -> VortexResult, @@ -210,6 +214,7 @@ where } // Code adapted from Rust standard library slice::binary_search_by +#[inline] fn search_sorted_side_idx VortexResult>( mut find: F, from: usize, @@ -276,11 +281,13 @@ impl IndexOrd for ArrayRef { } impl IndexOrd for [T] { + #[inline] fn index_cmp(&self, idx: usize, elem: &T) -> VortexResult> { // SAFETY: Used in search_sorted_by same as the standard library. The search_sorted ensures idx is in bounds Ok(unsafe { self.get_unchecked(idx) }.partial_cmp(elem)) } + #[inline] fn index_len(&self) -> usize { self.len() } diff --git a/vortex-buffer/src/bit/buf_mut.rs b/vortex-buffer/src/bit/buf_mut.rs index 6dac40db8ec..829b0fcf9cc 100644 --- a/vortex-buffer/src/bit/buf_mut.rs +++ b/vortex-buffer/src/bit/buf_mut.rs @@ -581,6 +581,7 @@ impl From> for BitBufferMut { } impl FromIterator for BitBufferMut { + #[inline] fn from_iter>(iter: T) -> Self { let mut iter = iter.into_iter();