Skip to content

Commit

Permalink
refactor(transformer): logical assignment transform: reduce identifie…
Browse files Browse the repository at this point in the history
…r cloning
  • Loading branch information
overlookmotel committed Oct 5, 2024
1 parent 1976c93 commit a79f973
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/oxc_transformer/src/es2021/logical_assignment_operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ impl<'a, 'ctx> LogicalAssignmentOperators<'a, 'ctx> {
) -> (Expression<'a>, AssignmentTarget<'a>) {
let reference = ctx.symbols_mut().get_reference_mut(ident.reference_id().unwrap());
*reference.flags_mut() = ReferenceFlags::Read;
let symbol_id = reference.symbol_id();
let left_expr = ctx.ast.expression_from_identifier_reference(ident.clone());

let assign_target =
AssignmentTarget::from(ctx.ast.simple_assignment_target_from_identifier_reference(
ctx.clone_identifier_reference(ident, ReferenceFlags::read_write()),
));
let ident = ctx.create_reference_id(
SPAN,
ident.name.clone(),
symbol_id,
ReferenceFlags::read_write(),
);
let assign_target = AssignmentTarget::from(
ctx.ast.simple_assignment_target_from_identifier_reference(ident),
);
(left_expr, assign_target)
}

Expand Down

0 comments on commit a79f973

Please sign in to comment.