From a1523c6cc81f75c09faef037c536610b128d69a9 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:07:12 +0000 Subject: [PATCH] perf(transformer): remove an allocation from arrow functions transform (#5412) Follow-up after #5356. No need to allocate a new `IdentifierReference` when we can just mutate the existing one. --- crates/oxc_transformer/src/es2015/arrow_functions.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/oxc_transformer/src/es2015/arrow_functions.rs b/crates/oxc_transformer/src/es2015/arrow_functions.rs index c124bacd0..3b54f4a50 100644 --- a/crates/oxc_transformer/src/es2015/arrow_functions.rs +++ b/crates/oxc_transformer/src/es2015/arrow_functions.rs @@ -158,9 +158,9 @@ impl<'a> Traverse<'a> for ArrowFunctions<'a> { if let JSXMemberExpressionObject::IdentifierReference(ident) = node { if ident.name == "this" { - let mut new_ident = self.get_this_name(ctx).create_read_reference(ctx); - new_ident.span = ident.span; - *node = ctx.ast.jsx_member_expression_object_from_identifier_reference(new_ident); + let new_ident = self.get_this_name(ctx).create_read_reference(ctx); + ident.name = new_ident.name; + ident.reference_id = new_ident.reference_id; } } }