Skip to content

Commit

Permalink
perf(transformer): remove an allocation from arrow functions transform (
Browse files Browse the repository at this point in the history
#5412)

Follow-up after #5356. No need to allocate a new `IdentifierReference` when we can just mutate the existing one.
  • Loading branch information
overlookmotel committed Sep 3, 2024
1 parent be4642f commit a1523c6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/oxc_transformer/src/es2015/arrow_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit a1523c6

Please sign in to comment.