rluvaton commented on code in PR #9393:
URL: https://github.com/apache/arrow-rs/pull/9393#discussion_r2793100391
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -101,14 +101,25 @@ pub struct MutableBuffer {
data: NonNull<u8>,
// invariant: len <= capacity
len: usize,
- layout: Layout,
+ capacity: usize,
+ // cached alignment, Layout reconstructed when needed
+ align: usize,
/// Memory reservation for tracking memory usage
#[cfg(feature = "pool")]
reservation: Mutex<Option<Box<dyn MemoryReservation>>>,
}
impl MutableBuffer {
+ /// Reconstruct Layout from cached capacity and alignment.
+ /// Only used in cold paths (alloc/dealloc/realloc).
+ #[inline]
+ fn layout(&self) -> Layout {
+ debug_assert!(self.align.is_power_of_two());
Review Comment:
if this is in cold path, should we use assert instead of debug_assert?
--
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]