Skip to content

Commit

Permalink
perf(allocator): use capacity hint (#4584)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucab authored Jul 31, 2024
1 parent 1aea15c commit 4c6d19d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/oxc_allocator/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ impl<'alloc, T> Vec<'alloc, T> {

#[inline]
pub fn from_iter_in<I: IntoIterator<Item = T>>(iter: I, allocator: &'alloc Allocator) -> Self {
let mut vec = vec::Vec::new_in(&**allocator);
let iter = iter.into_iter();
let capacity = iter.size_hint().1.unwrap_or(0);
let mut vec = vec::Vec::with_capacity_in(capacity, &**allocator);
vec.extend(iter);
Self(vec)
}
Expand Down

0 comments on commit 4c6d19d

Please sign in to comment.