Skip to content

Commit 7efea53

Browse files
committed
arrow-data: avoid allocating in get_last_run_end
The previous code called Buffer::from to get typed_data, which allocates a new MutableBuffer. Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
1 parent c9fca0b commit 7efea53

File tree

1 file changed

+1
-3
lines changed
  • arrow-data/src/transform

1 file changed

+1
-3
lines changed

arrow-data/src/transform/run.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ fn get_last_run_end<T: ArrowNativeType>(run_ends_data: &super::MutableArrayData)
2525
if run_ends_data.data.len == 0 {
2626
T::default()
2727
} else {
28-
// Convert buffer to typed slice and get the last element
29-
let buffer = Buffer::from(run_ends_data.data.buffer1.as_slice());
30-
let typed_slice: &[T] = buffer.typed_data();
28+
let typed_slice: &[T] = run_ends_data.data.buffer1.typed_data();
3129
if typed_slice.len() >= run_ends_data.data.len {
3230
typed_slice[run_ends_data.data.len - 1]
3331
} else {

0 commit comments

Comments
 (0)