hzuo commented on code in PR #5554:
URL: https://github.com/apache/arrow-rs/pull/5554#discussion_r1538444049
##########
arrow-ipc/src/writer.rs:
##########
@@ -1406,17 +1437,20 @@ fn write_buffer(
// make new index entry
buffers.push(crate::Buffer::new(offset, len));
- // padding and make offset 8 bytes aligned
- let pad_len = pad_to_8(len as u32) as i64;
- arrow_data.extend_from_slice(&vec![0u8; pad_len as usize][..]);
+ // padding and make offset aligned
+ let pad_len = pad_to_alignment(alignment, len as usize);
+ arrow_data.extend_from_slice(&PADDING[..pad_len]);
- Ok(offset + len + pad_len)
+ Ok(offset + len + (pad_len as i64))
}
-/// Calculate an 8-byte boundary and return the number of bytes needed to pad
to 8 bytes
+const PADDING: [u8; 64] = [0; 64];
Review Comment:
previously a Vec was being allocated every time padding was needed
--
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]