Skip to content

Commit

Permalink
Deref scalar buffer once (#1608)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored Dec 8, 2024
1 parent a4b2b05 commit 203dce8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions vortex-array/src/array/varbinview/compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ops::Deref;

use arrow_buffer::ScalarBuffer;
use itertools::Itertools;
use num_traits::AsPrimitive;
Expand Down Expand Up @@ -100,17 +102,21 @@ fn take_views<I: AsPrimitive<usize>>(
views: ScalarBuffer<u128>,
indices: &[I],
) -> ScalarBuffer<u128> {
ScalarBuffer::<u128>::from_iter(indices.iter().map(|i| views[i.as_()]))
// NOTE(ngates): this deref is not actually trivial, so we run it once.
let views_ref = views.deref();
ScalarBuffer::<u128>::from_iter(indices.iter().map(|i| views_ref[i.as_()]))
}

fn take_views_unchecked<I: AsPrimitive<usize>>(
views: ScalarBuffer<u128>,
indices: &[I],
) -> ScalarBuffer<u128> {
// NOTE(ngates): this deref is not actually trivial, so we run it once.
let views_ref = views.deref();
ScalarBuffer::<u128>::from_iter(
indices
.iter()
.map(|i| unsafe { *views.get_unchecked(i.as_()) }),
.map(|i| unsafe { *views_ref.get_unchecked(i.as_()) }),
)
}

Expand Down

0 comments on commit 203dce8

Please sign in to comment.