scovich commented on code in PR #7908:
URL: https://github.com/apache/arrow-rs/pull/7908#discussion_r2202816319


##########
parquet-variant/src/utils.rs:
##########
@@ -74,13 +74,32 @@ pub(crate) fn first_byte_from_slice(slice: &[u8]) -> 
Result<u8, ArrowError> {
         .ok_or_else(|| ArrowError::InvalidArgumentError("Received empty 
bytes".to_string()))
 }
 
+
 /// Helper to get a &str from a slice at the given offset and range, or an 
error if invalid.
+#[inline]
 pub(crate) fn string_from_slice(
     slice: &[u8],
     offset: usize,
     range: Range<usize>,
 ) -> Result<&str, ArrowError> {
-    str::from_utf8(slice_from_slice_at_offset(slice, offset, range)?)
+    let offset_buffer = match offset {
+        0 => slice_from_slice(slice, range)?,
+        _ => slice_from_slice_at_offset(slice, offset, range)?,
+    };

Review Comment:
   The branch to test for zero probably costs more than applying an offset of 
zero?



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to