Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inline on spit_at and smaller methods #1381

Merged
merged 1 commit into from Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/impl_internal_constructors.rs
Expand Up @@ -22,6 +22,7 @@ where S: RawData<Elem = A>
/// The caller must ensure that the data storage and pointer is valid.
///
/// See ArrayView::from_shape_ptr for general pointer validity documentation.
#[inline]
pub(crate) unsafe fn from_data_ptr(data: S, ptr: NonNull<A>) -> Self
{
let array = ArrayBase {
Expand Down Expand Up @@ -50,6 +51,7 @@ where
///
/// The caller needs to ensure that the new strides and dimensions are correct
/// for the array data.
#[inline]
pub(crate) unsafe fn with_strides_dim<E>(self, strides: E, dim: E) -> ArrayBase<S, E>
where E: Dimension
{
Expand Down
6 changes: 6 additions & 0 deletions src/impl_raw_views.rs
Expand Up @@ -21,6 +21,7 @@ where D: Dimension
RawArrayView::from_data_ptr(RawViewRepr::new(), ptr).with_strides_dim(strides, dim)
}

#[inline]
unsafe fn new_(ptr: *const A, dim: D, strides: D) -> Self
{
Self::new(nonnull_debug_checked_from_ptr(ptr as *mut A), dim, strides)
Expand Down Expand Up @@ -66,6 +67,7 @@ where D: Dimension
/// but it's not a complete check.
///
/// [`.offset()`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset
#[inline]
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *const A) -> Self
where Sh: Into<StrideShape<D>>
{
Expand Down Expand Up @@ -107,6 +109,7 @@ where D: Dimension
///
/// **Panics** if `axis` or `index` is out of bounds.
#[track_caller]
#[inline]
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
{
assert!(index <= self.len_of(axis));
Expand Down Expand Up @@ -234,6 +237,7 @@ where D: Dimension
RawArrayViewMut::from_data_ptr(RawViewRepr::new(), ptr).with_strides_dim(strides, dim)
}

#[inline]
unsafe fn new_(ptr: *mut A, dim: D, strides: D) -> Self
{
Self::new(nonnull_debug_checked_from_ptr(ptr), dim, strides)
Expand Down Expand Up @@ -279,6 +283,7 @@ where D: Dimension
/// but it's not a complete check.
///
/// [`.offset()`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset
#[inline]
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *mut A) -> Self
where Sh: Into<StrideShape<D>>
{
Expand Down Expand Up @@ -345,6 +350,7 @@ where D: Dimension
///
/// **Panics** if `axis` or `index` is out of bounds.
#[track_caller]
#[inline]
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
{
let (left, right) = self.into_raw_view().split_at(axis, index);
Expand Down
2 changes: 2 additions & 0 deletions src/impl_views/constructors.rs
Expand Up @@ -110,6 +110,7 @@ where D: Dimension
/// but it's not a complete check.
///
/// [`.offset()`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset
#[inline]
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *const A) -> Self
where Sh: Into<StrideShape<D>>
{
Expand Down Expand Up @@ -212,6 +213,7 @@ where D: Dimension
/// but it's not a complete check.
///
/// [`.offset()`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset
#[inline]
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *mut A) -> Self
where Sh: Into<StrideShape<D>>
{
Expand Down
1 change: 1 addition & 0 deletions src/impl_views/conversions.rs
Expand Up @@ -62,6 +62,7 @@ where D: Dimension
}

/// Converts to a raw array view.
#[inline]
pub(crate) fn into_raw_view(self) -> RawArrayView<A, D>
{
unsafe { RawArrayView::new(self.ptr, self.dim, self.strides) }
Expand Down
2 changes: 2 additions & 0 deletions src/impl_views/splitting.rs
Expand Up @@ -88,6 +88,7 @@ where D: Dimension
/// along Axis(1)
/// ```
#[track_caller]
#[inline]
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
{
unsafe {
Expand Down Expand Up @@ -137,6 +138,7 @@ where D: Dimension
///
/// **Panics** if `axis` or `index` is out of bounds.
#[track_caller]
#[inline]
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
{
unsafe {
Expand Down
1 change: 1 addition & 0 deletions src/shape_builder.rs
Expand Up @@ -82,6 +82,7 @@ impl<D> Strides<D>
}
}

#[inline]
pub(crate) fn is_custom(&self) -> bool
{
matches!(*self, Strides::Custom(_))
Expand Down