scovich commented on code in PR #7922: URL: https://github.com/apache/arrow-rs/pull/7922#discussion_r2207963894
########## 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: > I agree in theory it is not a great idea > > However in practice I think it is common to reserve capacity (allocate) based on the size hint and it is done several other places in this crate I was referring specifically to the _upper_ bound. All the code you link (**) only looks at the _lower_ bound, which is a lot less dangerous. (**) except [`FromIterator for BooleanArray`](https://github.com/apache/arrow-rs/blob/a2cc42639b4ad5579d052e6f2317a413e2407e0f/arrow-array/src/array/boolean_array.rs#L435-L434), for some reason. -- 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