Cintu07 commented on code in PR #10984:
URL: https://github.com/apache/arrow-rs/pull/10984#discussion_r3937604544
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -737,9 +737,32 @@ impl MutableBuffer {
///
/// This is similar to `from_trusted_len_iter_bool`, however, can be
significantly faster
/// as it eliminates the conditional `Iterator::next`
+ ///
+ /// # Panics
+ ///
+ /// Panics if the backing storage for `len` bits cannot be allocated. Use
+ /// [`MutableBuffer::try_collect_bool`] when `len` comes from untrusted
input.
#[inline]
- pub fn collect_bool<F: FnMut(usize) -> bool>(len: usize, mut f: F) -> Self
{
- let mut buffer: Vec<u64> = Vec::with_capacity(bit_util::ceil(len, 64));
+ pub fn collect_bool<F: FnMut(usize) -> bool>(len: usize, f: F) -> Self {
+ Self::try_collect_bool(len, f).unwrap_or_else(|e| panic!("{e}"))
+ }
+
+ /// Fallible version of [`MutableBuffer::collect_bool`].
+ ///
+ /// `len` is a bit count, so the reservation is `ceil(len / 64)` words.
Reserving that
Review Comment:
done in b58729e, reads ceil(len / 64) u64 slots now.
--
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]