From 4012260c170aec9b60399eff140227e48af9607c Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:48:38 +0000 Subject: [PATCH] refactor(ast): `AstBuilder::move_identifier_reference` do not allocate empty string (#4977) #4920 introduced `AstBuilder::move_identifier_reference`. Make this slightly cheaper by using a static empty `Atom` rather than relying on `"".into_in(allocator)` which allocates an empty string into arena. --- crates/oxc_ast/src/ast_builder_impl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/ast_builder_impl.rs b/crates/oxc_ast/src/ast_builder_impl.rs index 5f6c2580f..4f4a7f030 100644 --- a/crates/oxc_ast/src/ast_builder_impl.rs +++ b/crates/oxc_ast/src/ast_builder_impl.rs @@ -75,7 +75,7 @@ impl<'a> AstBuilder<'a> { self, expr: &mut IdentifierReference<'a>, ) -> IdentifierReference<'a> { - let dummy = self.identifier_reference(expr.span(), ""); + let dummy = self.identifier_reference(expr.span(), Atom::empty()); mem::replace(expr, dummy) }