From f4c1389e9973468d3b84dec43b5151f4726ab271 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 11 Jun 2024 06:41:15 +0000 Subject: [PATCH] perf(transformer): create `Vec` with capacity (#3613) Tiny optimization. Where we know the required capacity of a `Vec`, initialize it with that capacity. --- crates/oxc_transformer/src/react/jsx_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_transformer/src/react/jsx_source.rs b/crates/oxc_transformer/src/react/jsx_source.rs index 14ecd0945..2703476d9 100644 --- a/crates/oxc_transformer/src/react/jsx_source.rs +++ b/crates/oxc_transformer/src/react/jsx_source.rs @@ -131,7 +131,7 @@ impl<'a> ReactJsxSource<'a> { self.ctx.ast.object_property(SPAN, kind, key, value, None, false, false, false) }; - let mut properties = self.ctx.ast.new_vec(); + let mut properties = self.ctx.ast.new_vec_with_capacity(3); properties.push(ObjectPropertyKind::ObjectProperty(filename)); properties.push(ObjectPropertyKind::ObjectProperty(line_number)); properties.push(ObjectPropertyKind::ObjectProperty(column_number));