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

   ## Which issue does this PR close?
   
   N/A - Performance improvement
   
   ## Rationale
   
   `BitReader::get_value` had a TODO comment about avoiding a copy. The method 
was converting `v: u64` → `&[u8]` (via `as_bytes()`) → `[u8; N]` (via 
`array_from_slice`) → `T` (via `from_le_bytes`), which involves unnecessary 
byte slice intermediaries.
   
   ## What changes are included in this PR?
   
   - Add `from_u64` method to `FromBytes` trait that converts directly from the 
`u64` bit buffer value
   - For integer types: simple truncating cast (`v as Self`)
   - For float types: `from_bits` to preserve bit patterns (split out of the 
macro)
   - For bool: `v != 0`
   - For byte array types (ByteArray, FixedLenByteArray, Int96): 
`unreachable!()` since these have `BIT_CAPACITY: 0` and are never used with 
`get_value`
   - Replace `T::try_from_le_slice(v.as_bytes()).ok()` with 
`Some(T::from_u64(v))` in `get_value`
   
   ## Are these changes tested?
   
   Existing tests cover this path thoroughly (21 bit_util tests pass).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to