Skip to content

Commit

Permalink
improve utf8 take no null
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Nov 25, 2021
1 parent 05b9762 commit afa250b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions polars/polars-arrow/src/kernels/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,9 @@ pub unsafe fn take_no_null_utf8_iter_unchecked<I: IntoIterator<Item = usize>>(
) -> Arc<LargeStringArray> {
let iter = indices.into_iter().map(|idx| {
debug_assert!(idx < arr.len());
Some(arr.value_unchecked(idx))
arr.value_unchecked(idx)
});

Arc::new(LargeStringArray::from_trusted_len_iter_unchecked(iter))
Arc::new(MutableUtf8Array::<i64>::from_trusted_len_values_iter_unchecked(iter).into())
}

/// # Safety
Expand All @@ -282,6 +281,7 @@ pub unsafe fn take_utf8_iter_unchecked<I: IntoIterator<Item = usize>>(
) -> Arc<LargeStringArray> {
let validity = arr.validity().expect("should have nulls");
let iter = indices.into_iter().map(|idx| {
debug_assert!(idx < arr.len());
if validity.get_bit_unchecked(idx) {
Some(arr.value_unchecked(idx))
} else {
Expand Down

0 comments on commit afa250b

Please sign in to comment.