Skip to content

Commit

Permalink
refactor(transformer/arrow-functions): reduce repeated code (#8323)
Browse files Browse the repository at this point in the history
Follow-on after #8024. Pure refactor. Make `self.visit_statement(stmt)` only get called in one place, rather than 2.
  • Loading branch information
overlookmotel committed Jan 8, 2025
1 parent 62e3f7e commit 73d0025
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crates/oxc_transformer/src/common/arrow_function_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,12 +1141,8 @@ impl<'a> VisitMut<'a> for ConstructorBodyThisAfterSuperInserter<'a, '_> {
let mut new_stmts = vec![];

for (index, stmt) in statements.iter_mut().enumerate() {
let Statement::ExpressionStatement(expr_stmt) = stmt else {
self.visit_statement(stmt);
continue;
};

if expr_stmt.expression.is_super_call_expression() {
if matches!(stmt, Statement::ExpressionStatement(expr_stmt) if expr_stmt.expression.is_super_call_expression())
{
let assignment = self.create_assignment_to_this_temp_var();
let new_stmt = self.ctx.ast.statement_expression(SPAN, assignment);
new_stmts.push((index, new_stmt));
Expand Down

0 comments on commit 73d0025

Please sign in to comment.