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


##########
arrow-buffer/src/builder/mod.rs:
##########
@@ -387,9 +395,11 @@ impl<T: ArrowNativeType> Default for BufferBuilder<T> {
 
 impl<T: ArrowNativeType> Extend<T> for BufferBuilder<T> {
     fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
-        self.buffer.extend(iter.into_iter().inspect(|_| {
-            self.len += 1;
-        }))
+        let before = self.buffer.len();
+        self.buffer.extend(iter);
+        let added_bytes = self.buffer.len() - before;
+        debug_assert_eq!(added_bytes % std::mem::size_of::<T>(), 0);
+        self.len += added_bytes / std::mem::size_of::<T>();

Review Comment:
   Note: before if the iterator panicked in the 3rd item or something it would 
not leave the builder in inconsistent state, now it will as the length does not 
match the buffer anymore



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