alamb commented on code in PR #9393:
URL: https://github.com/apache/arrow-rs/pull/9393#discussion_r3092812422


##########
arrow-buffer/src/builder/mod.rs:
##########
@@ -404,9 +397,10 @@ impl<T: ArrowNativeType> From<Vec<T>> for BufferBuilder<T> 
{
 
 impl<T: ArrowNativeType> FromIterator<T> for BufferBuilder<T> {
     fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
-        let mut builder = Self::default();
-        builder.extend(iter);
-        builder
+        Self {

Review Comment:
   this seems nicer too



##########
arrow-buffer/src/builder/mod.rs:
##########
@@ -219,7 +215,10 @@ impl<T: ArrowNativeType> BufferBuilder<T> {
     #[inline]
     pub fn append_n(&mut self, n: usize, v: T) {
         self.reserve(n);
-        self.extend(std::iter::repeat_n(v, n))
+        for _ in 0..n {
+            // SAFETY: reserve ensures enough capacity for n elements

Review Comment:
   I think extend already reserves 
   
   
https://github.com/apache/arrow-rs/blob/1a169cd638aa4b72ccb4961e37e5014a66308718/arrow-buffer/src/buffer/mutable.rs#L793-L796
   
   
   
https://github.com/apache/arrow-rs/blob/1a169cd638aa4b72ccb4961e37e5014a66308718/arrow-buffer/src/buffer/mutable.rs#L829-L828
   



-- 
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