From ed748394be54b9e4e212717007b430aa169667e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 20 Jan 2025 01:04:58 +0900 Subject: [PATCH] perf(es/minifier): Parallelize handling of class members (#9900) **Description:** These methods were missing and it makes the minification of some files needlessly slow. --- .changeset/calm-frogs-search.md | 9 + .../swc_ecma_lints/src/rules/const_assign.rs | 6 + .../swc_ecma_lints/src/rules/no_dupe_args.rs | 6 + .../src/compress/optimize/util.rs | 154 +++++++++--------- .../src/compress/pure/mod.rs | 32 ++-- crates/swc_ecma_minifier/src/util/base54.rs | 50 +++--- .../src/rename/ops.rs | 6 + .../src/inline_globals.rs | 34 ++-- .../src/simplify/branch/mod.rs | 54 +++--- .../src/simplify/dce/mod.rs | 4 + .../src/simplify/expr/mod.rs | 110 +++++++------ 11 files changed, 262 insertions(+), 203 deletions(-) create mode 100644 .changeset/calm-frogs-search.md diff --git a/.changeset/calm-frogs-search.md b/.changeset/calm-frogs-search.md new file mode 100644 index 000000000000..a381922bcdce --- /dev/null +++ b/.changeset/calm-frogs-search.md @@ -0,0 +1,9 @@ +--- +swc_core: patch +swc_ecma_lints: patch +swc_ecma_transforms_base: patch +swc_ecma_transforms_optimization: patch +swc_ecma_minifier: patch +--- + +perf(es/minifier): Parallelize handling of class members diff --git a/crates/swc_ecma_lints/src/rules/const_assign.rs b/crates/swc_ecma_lints/src/rules/const_assign.rs index 38204497f05b..dfb470d622ee 100644 --- a/crates/swc_ecma_lints/src/rules/const_assign.rs +++ b/crates/swc_ecma_lints/src/rules/const_assign.rs @@ -108,6 +108,12 @@ impl Visit for ConstAssign<'_> { self.check(&Ident::from(n)); } + fn visit_class_members(&mut self, members: &[ClassMember]) { + self.maybe_par(cpu_count(), members, |v, member| { + member.visit_with(v); + }); + } + fn visit_expr_or_spreads(&mut self, n: &[ExprOrSpread]) { self.maybe_par(cpu_count(), n, |v, n| { n.visit_with(v); diff --git a/crates/swc_ecma_lints/src/rules/no_dupe_args.rs b/crates/swc_ecma_lints/src/rules/no_dupe_args.rs index 22904a9d651b..eec0e278ee1d 100644 --- a/crates/swc_ecma_lints/src/rules/no_dupe_args.rs +++ b/crates/swc_ecma_lints/src/rules/no_dupe_args.rs @@ -111,6 +111,12 @@ impl Visit for NoDupeArgs { f.visit_children_with(self); } + fn visit_class_members(&mut self, members: &[ClassMember]) { + self.maybe_par(cpu_count(), members, |v, member| { + member.visit_with(v); + }); + } + fn visit_constructor(&mut self, f: &Constructor) { check!(&f.params); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/util.rs b/crates/swc_ecma_minifier/src/compress/optimize/util.rs index e4224443ef70..c0cd7e3ac0c5 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/util.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/util.rs @@ -308,24 +308,6 @@ enum FinalizerMode { impl VisitMut for Finalizer<'_> { noop_visit_mut_type!(); - fn visit_mut_callee(&mut self, e: &mut Callee) { - e.visit_mut_children_with(self); - - if let Callee::Expr(e) = e { - self.check(e, FinalizerMode::Callee); - } - } - - fn visit_mut_member_expr(&mut self, e: &mut MemberExpr) { - e.visit_mut_children_with(self); - - if let MemberProp::Computed(ref mut prop) = e.prop { - if let Expr::Lit(Lit::Num(..)) = &*prop.expr { - self.check(&mut e.obj, FinalizerMode::MemberAccess); - } - } - } - fn visit_mut_bin_expr(&mut self, e: &mut BinExpr) { e.visit_mut_children_with(self); @@ -342,65 +324,17 @@ impl VisitMut for Finalizer<'_> { } } - fn visit_mut_var_declarators(&mut self, n: &mut Vec) { - n.visit_mut_children_with(self); - - n.retain(|v| !v.name.is_invalid()); - } - - fn visit_mut_var_declarator(&mut self, n: &mut VarDeclarator) { - n.visit_mut_children_with(self); - - if n.init.is_none() { - if let Pat::Ident(i) = &n.name { - if self.vars_to_remove.contains(&i.to_id()) { - n.name.take(); - } - } - } - } - - fn visit_mut_opt_var_decl_or_expr(&mut self, n: &mut Option) { - n.visit_mut_children_with(self); - - if let Some(VarDeclOrExpr::VarDecl(v)) = n { - if v.decls.is_empty() { - *n = None; - } - } - } - - fn visit_mut_stmt(&mut self, n: &mut Stmt) { - n.visit_mut_children_with(self); + fn visit_mut_callee(&mut self, e: &mut Callee) { + e.visit_mut_children_with(self); - if let Stmt::Decl(Decl::Var(v)) = n { - if v.decls.is_empty() { - n.take(); - } + if let Callee::Expr(e) = e { + self.check(e, FinalizerMode::Callee); } } - fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { - self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { - n.visit_mut_with(v); - }); - } - - fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { - self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { - n.visit_mut_with(v); - }); - } - - fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { - self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { - n.visit_mut_with(v); - }); - } - - fn visit_mut_exprs(&mut self, n: &mut Vec>) { - self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { - n.visit_mut_with(v); + fn visit_mut_class_members(&mut self, members: &mut Vec) { + self.maybe_par(*HEAVY_TASK_PARALLELS, members, |v, member| { + member.visit_mut_with(v); }); } @@ -436,17 +370,89 @@ impl VisitMut for Finalizer<'_> { n.visit_mut_children_with(self); } - fn visit_mut_stmts(&mut self, n: &mut Vec) { + fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { + self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { + n.visit_mut_with(v); + }); + } + + fn visit_mut_exprs(&mut self, n: &mut Vec>) { self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { n.visit_mut_with(v); }); } + fn visit_mut_member_expr(&mut self, e: &mut MemberExpr) { + e.visit_mut_children_with(self); + + if let MemberProp::Computed(ref mut prop) = e.prop { + if let Expr::Lit(Lit::Num(..)) = &*prop.expr { + self.check(&mut e.obj, FinalizerMode::MemberAccess); + } + } + } + fn visit_mut_module_items(&mut self, n: &mut Vec) { self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { n.visit_mut_with(v); }); } + + fn visit_mut_opt_var_decl_or_expr(&mut self, n: &mut Option) { + n.visit_mut_children_with(self); + + if let Some(VarDeclOrExpr::VarDecl(v)) = n { + if v.decls.is_empty() { + *n = None; + } + } + } + + fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { + self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { + n.visit_mut_with(v); + }); + } + + fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { + self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { + n.visit_mut_with(v); + }); + } + + fn visit_mut_stmt(&mut self, n: &mut Stmt) { + n.visit_mut_children_with(self); + + if let Stmt::Decl(Decl::Var(v)) = n { + if v.decls.is_empty() { + n.take(); + } + } + } + + fn visit_mut_stmts(&mut self, n: &mut Vec) { + self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { + n.visit_mut_with(v); + }); + } + + fn visit_mut_var_declarator(&mut self, n: &mut VarDeclarator) { + n.visit_mut_children_with(self); + + if n.init.is_none() { + if let Pat::Ident(i) = &n.name { + if self.vars_to_remove.contains(&i.to_id()) { + n.name.take(); + } + } + } + } + + fn visit_mut_var_declarators(&mut self, n: &mut Vec) { + n.visit_mut_children_with(self); + + n.retain(|v| !v.name.is_invalid()); + } } pub(crate) struct NormalMultiReplacer<'a> { diff --git a/crates/swc_ecma_minifier/src/compress/pure/mod.rs b/crates/swc_ecma_minifier/src/compress/pure/mod.rs index 133c1b826a04..f39f9745e41a 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/mod.rs @@ -184,7 +184,7 @@ impl Pure<'_> { where N: for<'aa> VisitMutWith> + Send + Sync, { - self.maybe_par(cpu_count() * 8, nodes, |v, node| { + self.maybe_par(cpu_count() * 2, nodes, |v, node| { node.visit_mut_with(v); }); } @@ -243,20 +243,6 @@ impl VisitMut for Pure<'_> { self.drop_arguments_of_symbol_call(e); } - fn visit_mut_opt_call(&mut self, opt_call: &mut OptCall) { - { - let ctx = Ctx { - is_callee: true, - ..self.ctx - }; - opt_call.callee.visit_mut_with(&mut *self.with_ctx(ctx)); - } - - opt_call.args.visit_mut_with(self); - - self.eval_spread_array(&mut opt_call.args); - } - fn visit_mut_class_member(&mut self, m: &mut ClassMember) { m.visit_mut_children_with(self); @@ -268,7 +254,7 @@ impl VisitMut for Pure<'_> { } fn visit_mut_class_members(&mut self, m: &mut Vec) { - m.visit_mut_children_with(self); + self.visit_par(m); m.retain(|m| { if let ClassMember::Empty(..) = m { @@ -673,6 +659,20 @@ impl VisitMut for Pure<'_> { e.args.visit_mut_with(self); } + fn visit_mut_opt_call(&mut self, opt_call: &mut OptCall) { + { + let ctx = Ctx { + is_callee: true, + ..self.ctx + }; + opt_call.callee.visit_mut_with(&mut *self.with_ctx(ctx)); + } + + opt_call.args.visit_mut_with(self); + + self.eval_spread_array(&mut opt_call.args); + } + fn visit_mut_opt_var_decl_or_expr(&mut self, n: &mut Option) { n.visit_mut_children_with(self); diff --git a/crates/swc_ecma_minifier/src/util/base54.rs b/crates/swc_ecma_minifier/src/util/base54.rs index 764f02051b85..5e469b2a3d36 100644 --- a/crates/swc_ecma_minifier/src/util/base54.rs +++ b/crates/swc_ecma_minifier/src/util/base54.rs @@ -326,6 +326,24 @@ impl Visit for CharFreqAnalyzer<'_> { visit_obj_and_computed!(); + fn visit_class_members(&mut self, members: &[ClassMember]) { + self.maybe_par(cpu_count(), members, |v, member| { + member.visit_with(v); + }); + } + + fn visit_expr_or_spreads(&mut self, n: &[ExprOrSpread]) { + self.maybe_par(cpu_count(), n, |v, n| { + n.visit_with(v); + }); + } + + fn visit_exprs(&mut self, exprs: &[Box]) { + self.maybe_par(cpu_count(), exprs, |v, expr| { + expr.visit_with(v); + }); + } + fn visit_ident(&mut self, i: &Ident) { if i.ctxt == self.unresolved_ctxt && i.sym != "arguments" { return; @@ -339,31 +357,9 @@ impl Visit for CharFreqAnalyzer<'_> { self.freq.scan(&i.sym, -1); } - fn visit_prop_name(&mut self, n: &PropName) { - match n { - PropName::Ident(_) => {} - PropName::Str(_) => {} - PropName::Num(_) => {} - PropName::Computed(e) => e.visit_with(self), - PropName::BigInt(_) => {} - } - } - /// This is preserved anyway fn visit_module_export_name(&mut self, _: &ModuleExportName) {} - fn visit_expr_or_spreads(&mut self, n: &[ExprOrSpread]) { - self.maybe_par(cpu_count(), n, |v, n| { - n.visit_with(v); - }); - } - - fn visit_exprs(&mut self, exprs: &[Box]) { - self.maybe_par(cpu_count(), exprs, |v, expr| { - expr.visit_with(v); - }); - } - fn visit_module_items(&mut self, items: &[ModuleItem]) { self.maybe_par(cpu_count(), items, |v, item| { item.visit_with(v); @@ -376,6 +372,16 @@ impl Visit for CharFreqAnalyzer<'_> { }); } + fn visit_prop_name(&mut self, n: &PropName) { + match n { + PropName::Ident(_) => {} + PropName::Str(_) => {} + PropName::Num(_) => {} + PropName::Computed(e) => e.visit_with(self), + PropName::BigInt(_) => {} + } + } + fn visit_prop_or_spreads(&mut self, n: &[PropOrSpread]) { self.maybe_par(cpu_count(), n, |v, n| { n.visit_with(v); diff --git a/crates/swc_ecma_transforms_base/src/rename/ops.rs b/crates/swc_ecma_transforms_base/src/rename/ops.rs index 16ef4755c0a0..3ae17d63b35a 100644 --- a/crates/swc_ecma_transforms_base/src/rename/ops.rs +++ b/crates/swc_ecma_transforms_base/src/rename/ops.rs @@ -522,6 +522,12 @@ where } } + fn visit_mut_class_members(&mut self, members: &mut Vec) { + self.maybe_par(cpu_count(), members, |v, member| { + member.visit_mut_with(v); + }); + } + fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { self.maybe_par(cpu_count() * 100, n, |v, n| { n.visit_mut_with(v); diff --git a/crates/swc_ecma_transforms_optimization/src/inline_globals.rs b/crates/swc_ecma_transforms_optimization/src/inline_globals.rs index 94abfca5f1e7..23522e2f5d10 100644 --- a/crates/swc_ecma_transforms_optimization/src/inline_globals.rs +++ b/crates/swc_ecma_transforms_optimization/src/inline_globals.rs @@ -65,6 +65,10 @@ impl Parallel for InlineGlobals { impl VisitMut for InlineGlobals { noop_visit_mut_type!(fail); + fn visit_mut_class_members(&mut self, members: &mut Vec) { + self.visit_mut_par(cpu_count(), members); + } + fn visit_mut_expr(&mut self, expr: &mut Expr) { if let Expr::Ident(Ident { ref sym, ctxt, .. }) = expr { if self.bindings.contains(&(sym.clone(), *ctxt)) { @@ -151,12 +155,24 @@ impl VisitMut for InlineGlobals { } } + fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { + self.visit_mut_par(cpu_count(), n); + } + + fn visit_mut_exprs(&mut self, n: &mut Vec>) { + self.visit_mut_par(cpu_count(), n); + } + fn visit_mut_module(&mut self, module: &mut Module) { self.bindings = Lrc::new(collect_decls(&*module)); module.visit_mut_children_with(self); } + fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { + self.visit_mut_par(cpu_count(), n); + } + fn visit_mut_prop(&mut self, p: &mut Prop) { p.visit_mut_children_with(self); @@ -176,26 +192,14 @@ impl VisitMut for InlineGlobals { } } - fn visit_mut_script(&mut self, script: &mut Script) { - self.bindings = Lrc::new(collect_decls(&*script)); - - script.visit_mut_children_with(self); - } - fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { self.visit_mut_par(cpu_count(), n); } - fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { - self.visit_mut_par(cpu_count(), n); - } - - fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { - self.visit_mut_par(cpu_count(), n); - } + fn visit_mut_script(&mut self, script: &mut Script) { + self.bindings = Lrc::new(collect_decls(&*script)); - fn visit_mut_exprs(&mut self, n: &mut Vec>) { - self.visit_mut_par(cpu_count(), n); + script.visit_mut_children_with(self); } } diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs index 06a8acfcac7d..66aaef46e084 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs @@ -74,6 +74,12 @@ impl Parallel for Remover { impl VisitMut for Remover { noop_visit_mut_type!(); + fn visit_mut_class_members(&mut self, members: &mut Vec) { + self.maybe_par(cpu_count(), members, |v, member| { + member.visit_mut_with(v); + }); + } + fn visit_mut_expr(&mut self, e: &mut Expr) { e.visit_mut_children_with(self); @@ -177,6 +183,18 @@ impl VisitMut for Remover { } } + fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { + self.maybe_par(cpu_count() * 8, n, |v, n| { + n.visit_mut_with(v); + }) + } + + fn visit_mut_exprs(&mut self, n: &mut Vec>) { + self.maybe_par(cpu_count() * 8, n, |v, n| { + n.visit_mut_with(v); + }) + } + fn visit_mut_for_stmt(&mut self, s: &mut ForStmt) { s.visit_mut_children_with(self); @@ -296,6 +314,12 @@ impl VisitMut for Remover { } } + fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { + self.maybe_par(cpu_count() * 8, n, |v, n| { + n.visit_mut_with(v); + }) + } + fn visit_mut_pat(&mut self, p: &mut Pat) { p.visit_mut_children_with(self); @@ -318,6 +342,12 @@ impl VisitMut for Remover { } } + fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { + self.maybe_par(cpu_count() * 8, n, |v, n| { + n.visit_mut_with(v); + }) + } + fn visit_mut_seq_expr(&mut self, e: &mut SeqExpr) { e.visit_mut_children_with(self); if e.exprs.is_empty() { @@ -1218,30 +1248,6 @@ impl VisitMut for Remover { } } - fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { - self.maybe_par(cpu_count() * 8, n, |v, n| { - n.visit_mut_with(v); - }) - } - - fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { - self.maybe_par(cpu_count() * 8, n, |v, n| { - n.visit_mut_with(v); - }) - } - - fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { - self.maybe_par(cpu_count() * 8, n, |v, n| { - n.visit_mut_with(v); - }) - } - - fn visit_mut_exprs(&mut self, n: &mut Vec>) { - self.maybe_par(cpu_count() * 8, n, |v, n| { - n.visit_mut_with(v); - }) - } - fn visit_mut_var_declarators(&mut self, n: &mut Vec) { self.maybe_par(cpu_count() * 8, n, |v, n| { n.visit_mut_with(v); diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs index 6c4e463b4e42..985027e61fd4 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs @@ -701,6 +701,10 @@ impl VisitMut for TreeShaker { self.in_block_stmt = old_in_block_stmt; } + fn visit_mut_class_members(&mut self, members: &mut Vec) { + self.visit_mut_par(cpu_count() * 8, members); + } + fn visit_mut_decl(&mut self, n: &mut Decl) { n.visit_mut_children_with(self); diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs index 3e481e4ba706..319d6b2c7705 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs @@ -1288,6 +1288,29 @@ impl VisitMut for SimplifyExpr { self.in_callee = old_in_callee; } + fn visit_mut_class_members(&mut self, members: &mut Vec) { + self.maybe_par(cpu_count(), members, |v, member| { + member.visit_mut_with(v); + }); + } + + fn visit_mut_export_default_expr(&mut self, expr: &mut ExportDefaultExpr) { + fn is_paren_wrap_fn_or_class(expr: &mut Expr, visitor: &mut SimplifyExpr) -> bool { + match &mut *expr { + Expr::Fn(..) | Expr::Class(..) => { + expr.visit_mut_children_with(visitor); + true + } + Expr::Paren(p) => is_paren_wrap_fn_or_class(&mut p.expr, visitor), + _ => false, + } + } + + if !is_paren_wrap_fn_or_class(&mut expr.expr, self) { + expr.visit_mut_children_with(self); + } + } + fn visit_mut_expr(&mut self, expr: &mut Expr) { if let Expr::Unary(UnaryExpr { op: op!("delete"), .. @@ -1443,21 +1466,23 @@ impl VisitMut for SimplifyExpr { }; } - fn visit_mut_export_default_expr(&mut self, expr: &mut ExportDefaultExpr) { - fn is_paren_wrap_fn_or_class(expr: &mut Expr, visitor: &mut SimplifyExpr) -> bool { - match &mut *expr { - Expr::Fn(..) | Expr::Class(..) => { - expr.visit_mut_children_with(visitor); - true - } - Expr::Paren(p) => is_paren_wrap_fn_or_class(&mut p.expr, visitor), - _ => false, - } - } + fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { + self.maybe_par(cpu_count(), n, |v, n| { + n.visit_mut_with(v); + }); + } - if !is_paren_wrap_fn_or_class(&mut expr.expr, self) { - expr.visit_mut_children_with(self); - } + fn visit_mut_exprs(&mut self, n: &mut Vec>) { + self.maybe_par(cpu_count(), n, |v, n| { + n.visit_mut_with(v); + }); + } + + fn visit_mut_for_head(&mut self, n: &mut ForHead) { + let old = self.is_modifying; + self.is_modifying = true; + n.visit_mut_children_with(self); + self.is_modifying = old; } fn visit_mut_module_items(&mut self, n: &mut Vec) { @@ -1494,6 +1519,12 @@ impl VisitMut for SimplifyExpr { n.visit_mut_children_with(self); } + fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { + self.maybe_par(cpu_count(), n, |v, n| { + n.visit_mut_with(v); + }); + } + fn visit_mut_pat(&mut self, p: &mut Pat) { let old_in_callee = self.in_callee; self.in_callee = false; @@ -1517,6 +1548,12 @@ impl VisitMut for SimplifyExpr { } } + fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { + self.maybe_par(cpu_count(), n, |v, n| { + n.visit_mut_with(v); + }); + } + /// Drops unused values fn visit_mut_seq_expr(&mut self, e: &mut SeqExpr) { if e.exprs.is_empty() { @@ -1621,20 +1658,6 @@ impl VisitMut for SimplifyExpr { self.changed |= child.changed; } - fn visit_mut_update_expr(&mut self, n: &mut UpdateExpr) { - let old = self.is_modifying; - self.is_modifying = true; - n.arg.visit_mut_with(self); - self.is_modifying = old; - } - - fn visit_mut_for_head(&mut self, n: &mut ForHead) { - let old = self.is_modifying; - self.is_modifying = true; - n.visit_mut_children_with(self); - self.is_modifying = old; - } - fn visit_mut_tagged_tpl(&mut self, n: &mut TaggedTpl) { let old = self.in_callee; self.in_callee = true; @@ -1647,32 +1670,15 @@ impl VisitMut for SimplifyExpr { self.in_callee = old; } - fn visit_mut_with_stmt(&mut self, n: &mut WithStmt) { - n.obj.visit_mut_with(self); - } - - fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { - self.maybe_par(cpu_count(), n, |v, n| { - n.visit_mut_with(v); - }); - } - - fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { - self.maybe_par(cpu_count(), n, |v, n| { - n.visit_mut_with(v); - }); - } - - fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { - self.maybe_par(cpu_count(), n, |v, n| { - n.visit_mut_with(v); - }); + fn visit_mut_update_expr(&mut self, n: &mut UpdateExpr) { + let old = self.is_modifying; + self.is_modifying = true; + n.arg.visit_mut_with(self); + self.is_modifying = old; } - fn visit_mut_exprs(&mut self, n: &mut Vec>) { - self.maybe_par(cpu_count(), n, |v, n| { - n.visit_mut_with(v); - }); + fn visit_mut_with_stmt(&mut self, n: &mut WithStmt) { + n.obj.visit_mut_with(self); } }