Skip to content

Commit

Permalink
Partial revert
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Apr 25, 2024
1 parent 256a910 commit e80968d
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions crates/swc_ecma_minifier/src/compress/optimize/iife.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, mem::swap};

use rustc_hash::{FxHashMap, FxHashSet};
use rustc_hash::FxHashMap;
use swc_common::{pass::Either, util::take::Take, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::{
Expand Down Expand Up @@ -157,35 +157,13 @@ impl Optimizer<'_> {
}
}

fn clean_params(callee: &mut Expr, vars: &FxHashSet<Id>) {
fn clean_params(callee: &mut Expr) {
match callee {
Expr::Arrow(callee) => {
for p in callee.params.iter_mut().rev() {
if let Pat::Ident(param) = p {
if vars.contains(&param.to_id()) {
p.take();
continue;
}
}

break;
}

// Drop invalid nodes
callee.params.retain(|p| !p.is_invalid())
}
Expr::Fn(callee) => {
for p in callee.function.params.iter_mut().rev() {
if let Pat::Ident(param) = &mut p.pat {
if vars.contains(&param.to_id()) {
p.pat.take();
continue;
}
}

break;
}

// Drop invalid nodes
callee.function.params.retain(|p| !p.pat.is_invalid())
}
Expand Down Expand Up @@ -310,8 +288,6 @@ impl Optimizer<'_> {
return;
}

let var_keys = vars.keys().cloned().collect();

let ctx = Ctx {
in_fn_like: true,
top_level: false,
Expand All @@ -332,7 +308,7 @@ impl Optimizer<'_> {
}
}

clean_params(callee, &var_keys);
clean_params(callee);
}
}

Expand Down

0 comments on commit e80968d

Please sign in to comment.