refactor(minifier): remove parens must happen on enter (#8060)

This commit is contained in:
Boshen 2024-12-23 06:56:36 +00:00
parent 10a1fd57e5
commit 8b54d898b5
2 changed files with 1 additions and 5 deletions

View file

@ -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>);
}
@ -259,7 +257,6 @@ impl<'a> Traverse<'a> for PeepholeOptimizations {
}
pub struct DeadCodeElimination {
x0_remove_syntax: RemoveSyntax,
x1_peephole_fold_constants: PeepholeFoldConstants,
x2_peephole_remove_dead_code: PeepholeRemoveDeadCode,
}
@ -267,7 +264,6 @@ pub struct DeadCodeElimination {
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(),
}
@ -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);
}

View file

@ -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);
}
}