ctsk opened a new pull request, #7573:
URL: https://github.com/apache/arrow-rs/pull/7573

   # Which issue does this PR close?
   
   `GenericByteArray::value_unchecked` permits `unsafe` code, but still 
introduces a check due to `unwrap` being called here:
   
   ```diff
           let b = std::slice::from_raw_parts(
   -           self.value_data.as_ptr().offset(start.to_isize().unwrap()),
   -           (end - start).to_usize().unwrap(),
   +           
self.value_data.as_ptr().offset(start.to_isize().unwrap_unchecked()),
   +           (end - start).to_usize().unwrap_unchecked(),
           );
   ```
   
   I believe it is sensible to use `unwrap_unsafe` here instead. While the 
compiler may be able to prune the first unwrap as unreachable, I believe it can 
**not** prove at compile time that `end >= start` and eliminate the second 
unwrap. This is an invariant of GenericByteArray.
   
   # Are there any user-facing changes?
   
   No.


-- 
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