You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/20 19:50:36 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #1825: Replace RawPtrBox with ScalarBuffer, reduce `unsafe` usage (#1811)

viirya commented on code in PR #1825:
URL: https://github.com/apache/arrow-rs/pull/1825#discussion_r1027343300


##########
arrow/src/array/array_primitive.rs:
##########
@@ -100,17 +92,15 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
     /// caller must ensure that the passed in offset is less than the array len()
     #[inline]
     pub unsafe fn value_unchecked(&self, i: usize) -> T::Native {
-        let offset = i + self.offset();
-        *self.raw_values.as_ptr().add(offset)
+        *self.raw_values.get_unchecked(i)

Review Comment:
   This `value_unchecked` seems more costly than before? Previously it simply takes value from the ptr (with an offset).
   
   But `get_unchecked` on `ScalarBuffer` will create a slice first?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org