Skip to content

Commit 337147c

Browse files
committed
w
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 49ec12a commit 337147c

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

vortex-array/src/arrays/primitive/array/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ impl PrimitiveData {
596596
}
597597

598598
/// Try to extract a mutable buffer from the PrimitiveData with zero copy.
599+
///
600+
/// # Panic
601+
/// If the buffer is not of type T this will panic
599602
pub fn try_into_buffer_mut<T: NativePType>(self) -> Result<BufferMut<T>, Buffer<T>> {
600603
if T::PTYPE != self.ptype() {
601604
vortex_panic!(

vortex-array/src/arrays/primitive/compute/cast.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,9 @@ where
136136

137137
// If F and T have the same byte width, try to take unique ownership of the buffer.
138138
let same_bit_width = F::PTYPE.byte_width() == T::PTYPE.byte_width();
139-
let owned: Option<BufferMut<F>> = if same_bit_width {
140-
array.into_owned().try_into_buffer_mut::<F>().ok()
141-
} else {
142-
None
143-
};
139+
let owned: Option<BufferMut<F>> = same_bit_width
140+
.then(|| array.into_owned().try_into_buffer_mut::<F>().ok())
141+
.flatten();
144142
let values: &[F] = array.as_slice::<F>();
145143

146144
if infallible {

0 commit comments

Comments
 (0)