mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
perf(allocator): use capacity hint (#4584)
This commit is contained in:
parent
1aea15c1ab
commit
4c6d19d440
1 changed files with 3 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue