Skip to content

Commit

Permalink
refactor(minifier): make Prepass Copy (#3603)
Browse files Browse the repository at this point in the history
Similar to #3602. `Prepass<'a>` only contains `AstBuilder<'a>`, which only contains shared ref `&'a Allocator`. So make `Prepass` `Copy` and pass around `Prepass<'a>` instead of `&Prepass<'a>` (so avoiding extra indirection).
  • Loading branch information
overlookmotel committed Jun 10, 2024
1 parent 08f1010 commit e90e6a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/oxc_minifier/src/compressor/prepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use oxc_ast::visit::walk_mut::{walk_expression_mut, walk_statements_mut};
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstBuilder, VisitMut};

#[derive(Clone, Copy)]
pub struct Prepass<'a> {
ast: AstBuilder<'a>,
}
Expand All @@ -17,7 +18,7 @@ impl<'a> Prepass<'a> {
self.visit_program(program);
}

fn strip_parenthesized_expression(&self, expr: &mut Expression<'a>) {
fn strip_parenthesized_expression(self, expr: &mut Expression<'a>) {
if let Expression::ParenthesizedExpression(paren_expr) = expr {
*expr = self.ast.move_expression(&mut paren_expr.expression);
self.strip_parenthesized_expression(expr);
Expand Down

0 comments on commit e90e6a2

Please sign in to comment.