scovich commented on code in PR #7922:
URL: https://github.com/apache/arrow-rs/pull/7922#discussion_r2205958233


##########
parquet-variant/src/builder.rs:
##########
@@ -402,6 +402,11 @@ impl<S: AsRef<str>> FromIterator<S> for MetadataBuilder {
 
 impl<S: AsRef<str>> Extend<S> for MetadataBuilder {
     fn extend<T: IntoIterator<Item = S>>(&mut self, iter: T) {
+        let iter = iter.into_iter();
+        let (min, max) = iter.size_hint();
+
+        self.field_names.reserve(max.unwrap_or(min));
+
         for field_name in iter {
             self.upsert_field_name(field_name.as_ref());

Review Comment:
   The upper bound of the size hint is allowed to be `usize::MAX`. We probably 
shouldn't try to reserve that many field names?



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to