Skip to content

Commit

Permalink
refactor(minifier): remove parens must happen on enter
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 23, 2024
1 parent f79e9ad commit 8ecd16c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 0 additions & 5 deletions crates/oxc_minifier/src/ast_passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub use peephole_substitute_alternate_syntax::PeepholeSubstituteAlternateSyntax;
pub use remove_syntax::RemoveSyntax;
pub use statement_fusion::StatementFusion;

use crate::CompressOptions;

pub trait CompressorPass<'a>: Traverse<'a> {
fn build(&mut self, program: &mut Program<'a>, ctx: &mut ReusableTraverseCtx<'a>);
}
Expand Down Expand Up @@ -259,15 +257,13 @@ impl<'a> Traverse<'a> for PeepholeOptimizations {
}

pub struct DeadCodeElimination {
x0_remove_syntax: RemoveSyntax,
x1_peephole_fold_constants: PeepholeFoldConstants,
x2_peephole_remove_dead_code: PeepholeRemoveDeadCode,
}

impl DeadCodeElimination {
pub fn new() -> Self {
Self {
x0_remove_syntax: RemoveSyntax::new(CompressOptions::all_false()),
x1_peephole_fold_constants: PeepholeFoldConstants::new(),
x2_peephole_remove_dead_code: PeepholeRemoveDeadCode::new(),
}
Expand All @@ -294,7 +290,6 @@ impl<'a> Traverse<'a> for DeadCodeElimination {
}

fn exit_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
self.x0_remove_syntax.exit_expression(expr, ctx);
self.x1_peephole_fold_constants.exit_expression(expr, ctx);
self.x2_peephole_remove_dead_code.exit_expression(expr, ctx);
}
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_minifier/src/compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl<'a> Compressor<'a> {
program: &mut Program<'a>,
) {
let mut ctx = ReusableTraverseCtx::new(scopes, symbols, self.allocator);
RemoveSyntax::new(self.options).build(program, &mut ctx);
DeadCodeElimination::new().build(program, &mut ctx);
}
}

0 comments on commit 8ecd16c

Please sign in to comment.