mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
perf(ast): AstBuilder::vec1 use Vec::from_array_in (#7334)
`AstBuilder::vec1` can use `Vec::from_array_in` rather than creating a `Vec` and then pushing to it. This should optimize better.
This commit is contained in:
parent
510b95d6c4
commit
c84e892380
1 changed files with 1 additions and 3 deletions
|
|
@ -56,9 +56,7 @@ impl<'a> AstBuilder<'a> {
|
||||||
/// Create a new arena-allocated [`Vec`] initialized with a single element.
|
/// Create a new arena-allocated [`Vec`] initialized with a single element.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn vec1<T>(self, value: T) -> Vec<'a, T> {
|
pub fn vec1<T>(self, value: T) -> Vec<'a, T> {
|
||||||
let mut vec = self.vec_with_capacity(1);
|
self.vec_from_array([value])
|
||||||
vec.push(value);
|
|
||||||
vec
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Collect an iterator into a new arena-allocated [`Vec`].
|
/// Collect an iterator into a new arena-allocated [`Vec`].
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue