From e90e6a2a7c4b1246806a2131fa25351d45f1c825 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:17:44 +0000 Subject: [PATCH] refactor(minifier): make `Prepass` `Copy` (#3603) 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). --- crates/oxc_minifier/src/compressor/prepass.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/oxc_minifier/src/compressor/prepass.rs b/crates/oxc_minifier/src/compressor/prepass.rs index a00c881e5b8e9..e73f64d5af3e8 100644 --- a/crates/oxc_minifier/src/compressor/prepass.rs +++ b/crates/oxc_minifier/src/compressor/prepass.rs @@ -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>, } @@ -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);