mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
perf(allocator): use lower bound of size hint when creating Vecs from an iterator (#6194)
This commit is contained in:
parent
70d4c569d8
commit
5db9b3002c
1 changed files with 2 additions and 1 deletions
|
|
@ -95,7 +95,8 @@ impl<'alloc, T> Vec<'alloc, T> {
|
|||
#[inline]
|
||||
pub fn from_iter_in<I: IntoIterator<Item = T>>(iter: I, allocator: &'alloc Allocator) -> Self {
|
||||
let iter = iter.into_iter();
|
||||
let capacity = iter.size_hint().1.unwrap_or(0);
|
||||
let hint = iter.size_hint();
|
||||
let capacity = hint.1.unwrap_or(hint.0);
|
||||
let mut vec = vec::Vec::with_capacity_in(capacity, &**allocator);
|
||||
vec.extend(iter);
|
||||
Self(vec)
|
||||
|
|
|
|||
Loading…
Reference in a new issue