Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ impl<'a> PeepholeOptimizations {
_ => {}
}
}

if self.is_current_function_changed() {
stmts.retain(|stmt| !matches!(stmt, Statement::EmptyStatement(_)));
}
}

fn collapse_expr_into_for(
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_minifier/src/peephole/minimize_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl<'a> PeepholeOptimizations {
let mut local_change = false;
self.try_replace_if(stmts, &mut local_change, ctx);
if local_change {
stmts.retain(|stmt| !matches!(stmt, Statement::EmptyStatement(_)));
changed = local_change;
} else {
break;
Expand Down
7 changes: 2 additions & 5 deletions crates/oxc_minifier/src/peephole/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ impl<'a> PeepholeOptimizations {
*current_changed = true;
}

pub fn is_current_function_changed(&self) -> bool {
let (_, _, current_changed) = self.current_function.last();
*current_changed
}

#[inline]
fn is_prev_function_changed(&self) -> bool {
let (_, prev_changed, _) = self.current_function.last();
Expand Down Expand Up @@ -146,6 +141,7 @@ impl<'a> Traverse<'a> for PeepholeOptimizations {
self.collapse_variable_declarations(stmts, ctx);
self.minimize_conditions_exit_statements(stmts, ctx);
self.remove_dead_code_exit_statements(stmts, ctx);
stmts.retain(|stmt| !matches!(stmt, Statement::EmptyStatement(_)));
}

fn exit_statement(&mut self, stmt: &mut Statement<'a>, ctx: &mut TraverseCtx<'a>) {
Expand Down Expand Up @@ -337,6 +333,7 @@ impl<'a> Traverse<'a> for DeadCodeElimination {

fn exit_statements(&mut self, stmts: &mut Vec<'a, Statement<'a>>, ctx: &mut TraverseCtx<'a>) {
self.inner.remove_dead_code_exit_statements(stmts, Ctx(ctx));
stmts.retain(|stmt| !matches!(stmt, Statement::EmptyStatement(_)));
}

fn exit_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
Expand Down
3 changes: 0 additions & 3 deletions crates/oxc_minifier/src/peephole/remove_dead_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ impl<'a, 'b> PeepholeOptimizations {
ctx: Ctx<'a, '_>,
) {
self.dead_code_elimination(stmts, ctx);
if stmts.iter().any(|stmt| matches!(stmt, Statement::EmptyStatement(_))) {
stmts.retain(|stmt| !matches!(stmt, Statement::EmptyStatement(_)));
}
}

pub fn remove_dead_code_exit_statement(&mut self, stmt: &mut Statement<'a>, ctx: Ctx<'a, '_>) {
Expand Down
Loading