rluvaton commented on code in PR #8653:
URL: https://github.com/apache/arrow-rs/pull/8653#discussion_r2443489595
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -222,6 +222,82 @@ impl MutableBuffer {
}
}
+ /// Creates a new [`MutableBuffer`] by repeating the contents of
`slice_to_repeat`
+ /// `repeat_count` times.
+ pub fn new_repeated<T: ArrowNativeType>(repeat_count: usize,
slice_to_repeat: &[T]) -> Self {
+ if slice_to_repeat.is_empty() || repeat_count == 0 {
+ return Self::new(0);
+ }
+
+ // If we keep extending from ourself we will reach it pretty fast
+ let value_len = slice_to_repeat.len();
+ let final_len = repeat_count * value_len;
+ let mut mutable = Self::with_capacity(final_len);
+
+ mutable.push_slice_repeated(repeat_count, slice_to_repeat);
+
+ mutable
+ }
+
+ /// Adding to this mutable buffer `slice_to_repeat` repeated
`repeat_count` times.
+ pub fn push_slice_repeated<T: ArrowNativeType>(
Review Comment:
I kinda like my idea for copy in double each time to reduce the amount of
memcpy calls
--
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]