diff --git a/src/base/storage.rs b/src/base/storage.rs index 80a6a2d8..e7439552 100644 --- a/src/base/storage.rs +++ b/src/base/storage.rs @@ -72,16 +72,7 @@ pub unsafe trait Storage: Debug + Sized { /// Gets the address of the i-th matrix component without performing bound-checking. #[inline] unsafe fn get_address_unchecked_linear(&self, i: usize) -> *const N { - let shape = self.shape(); - if shape.0.value() * shape.1.value() == 0 { - // If we have a zero-size matrix, our pointer must - // be dangling. Instead of calling 'offset', we - // just re-use our pointer, since actually using - // it would be undefined behavior - self.ptr() - } else { - self.ptr().offset(i as isize) - } + self.ptr().wrapping_offset(i as isize) } /// Gets the address of the i-th matrix component without performing bound-checking. @@ -133,16 +124,7 @@ pub unsafe trait StorageMut: Storage { /// Gets the mutable address of the i-th matrix component without performing bound-checking. #[inline] unsafe fn get_address_unchecked_linear_mut(&mut self, i: usize) -> *mut N { - let shape = self.shape(); - if shape.0.value() * shape.1.value() == 0 { - // If we have a zero-size matrix, our pointer must - // be dangling. Instead of calling 'offset', we - // just re-use our pointer, since actually using - // it would be undefined behavior - self.ptr_mut() - } else { - self.ptr_mut().offset(i as isize) - } + self.ptr_mut().wrapping_offset(i as isize) } /// Gets the mutable address of the i-th matrix component without performing bound-checking.