Repository: swc-project/swc
File: crates/swc_ecma_transformer/src/es2021/logical_assignment_operators.rs (Rust)

Code before:
        let span = assign_expr.span;

        // Generate left expression and assignment target
        let (left_expr, assign_target) = match left {
            // `a &&= c` -> `a && (a = c)`
            SimpleAssignTarget::Ident(ident) => {
                let left_expr = Box::new(Expr::Ident(ident.id.clone()));
                let assign_target = left.clone();
                (left_expr, assign_target)
            }

            // `a.b &&= c` -> `var _a; (_a = a).b && (_a.b = c)`
            SimpleAssignTarget::Member(member_expr) => {
                self.transform_member_expression(member_expr, ctx)
            }

            // `super.prop &&= c` -> handle super property
            SimpleAssignTarget::SuperProp(super_prop_expr) => {
                self.transform_super_prop(super_prop_expr, ctx)
            }

            // Other cases like optional member expressions
            _ => {
                let left_expr: Box<Expr> = left.clone().into();
                (left_expr.clone(), left.clone())
            }
        };

        // Create assignment: `assign_target = right`
        let assignment = Box::new(Expr::Assign(AssignExpr {
            span: DUMMY_SP,
            op: AssignOp::Assign,
            left: AssignTarget::Simple(assign_target),
            right: assign_expr.right.take(),
        }));

        // Create binary expression: `left_expr op assignment`
        *expr = Expr::Bin(BinExpr {
            span,
            op,
            left: left_expr,
            right: assignment,
        });
    }
}

impl LogicalAssignmentOperatorsPass {
    fn transform_member_expression(
        &mut self,
        member_expr: &mut MemberExpr,
        ctx: &mut TraverseCtx,

Review comment (suggestion):
Unnecessary clone operation. The variable `left_expr` is created from `left.clone()` and then immediately cloned again in the return statement. Since `left_expr` is not used after this point, it can be moved directly without cloning. Change `(left_expr.clone(), left.clone())` to `(left_expr, left.clone())`.
```suggestion
                (left_expr, left.clone())
```

Code after:

        let span = assign_expr.span;

        // Generate left expression and assignment target
        let (left_expr, assign_target) = match left {
            // `a &&= c` -> `a && (a = c)`
            SimpleAssignTarget::Ident(ident) => {
                let left_expr = Box::new(Expr::Ident(ident.id.clone()));
                let assign_target = left.clone();
                (left_expr, assign_target)
            }

            // `a.b &&= c` -> `var _a; (_a = a).b && (_a.b = c)`
            SimpleAssignTarget::Member(member_expr) => {
                self.transform_member_expression(member_expr, ctx)
            }

            // `super.prop &&= c` -> handle super property
            SimpleAssignTarget::SuperProp(super_prop_expr) => {
                self.transform_super_prop(super_prop_expr, ctx)
            }

            // Other cases like optional member expressions
            _ => {
                let left_expr: Box<Expr> = left.clone().into();
                (left_expr.clone(), left.clone())
            }
        };

        // Create assignment: `assign_target = right`
        let assignment = Box::new(Expr::Assign(AssignExpr {
            span: DUMMY_SP,
            op: AssignOp::Assign,
            left: AssignTarget::Simple(assign_target),
            right: assign_expr.right.take(),
        }));

        // Create binary expression: `left_expr op assignment`
        *expr = Expr::Bin(BinExpr {
            span,
            op,
            left: left_expr,
            right: assignment,
        });
    }
}

impl LogicalAssignmentOperatorsPass {
    fn transform_member_expression(
        &mut self,
        member_expr: &mut MemberExpr,