Skip to content

Commit 4e6001c

Browse files
authored
perf(es/lints): Make rules not parallel (#10772)
**Description:** Those are very slow in `rayon` mode
1 parent 5d3ce83 commit 4e6001c

File tree

3 files changed

+6
-105
lines changed

3 files changed

+6
-105
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
swc_ecma_lints: patch
3+
---
4+
5+
perf(es/lints): Make rules not parallel

crates/swc_ecma_lints/src/rules/const_assign.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use rustc_hash::FxHashMap;
22
use swc_common::{errors::HANDLER, Span};
33
use swc_ecma_ast::*;
4-
use swc_ecma_utils::parallel::{cpu_count, Parallel, ParallelExt};
54
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
65

76
use crate::rule::Rule;
@@ -59,14 +58,6 @@ struct ConstAssign<'a> {
5958
is_pat_decl: bool,
6059
}
6160

62-
impl Parallel for ConstAssign<'_> {
63-
fn create(&self) -> Self {
64-
*self
65-
}
66-
67-
fn merge(&mut self, _: Self) {}
68-
}
69-
7061
impl ConstAssign<'_> {
7162
fn check(&mut self, id: &Ident) {
7263
if self.is_pat_decl {
@@ -109,48 +100,6 @@ impl Visit for ConstAssign<'_> {
109100
self.check(&Ident::from(n));
110101
}
111102

112-
fn visit_class_members(&mut self, members: &[ClassMember]) {
113-
self.maybe_par(cpu_count(), members, |v, member| {
114-
member.visit_with(v);
115-
});
116-
}
117-
118-
fn visit_expr_or_spreads(&mut self, n: &[ExprOrSpread]) {
119-
self.maybe_par(cpu_count(), n, |v, n| {
120-
n.visit_with(v);
121-
});
122-
}
123-
124-
fn visit_exprs(&mut self, exprs: &[Box<Expr>]) {
125-
self.maybe_par(cpu_count(), exprs, |v, expr| {
126-
expr.visit_with(v);
127-
});
128-
}
129-
130-
fn visit_module_items(&mut self, items: &[ModuleItem]) {
131-
self.maybe_par(cpu_count(), items, |v, item| {
132-
item.visit_with(v);
133-
});
134-
}
135-
136-
fn visit_opt_vec_expr_or_spreads(&mut self, n: &[Option<ExprOrSpread>]) {
137-
self.maybe_par(cpu_count(), n, |v, n| {
138-
n.visit_with(v);
139-
});
140-
}
141-
142-
fn visit_prop_or_spreads(&mut self, n: &[PropOrSpread]) {
143-
self.maybe_par(cpu_count(), n, |v, n| {
144-
n.visit_with(v);
145-
});
146-
}
147-
148-
fn visit_stmts(&mut self, stmts: &[Stmt]) {
149-
self.maybe_par(cpu_count(), stmts, |v, stmt| {
150-
stmt.visit_with(v);
151-
});
152-
}
153-
154103
fn visit_update_expr(&mut self, n: &UpdateExpr) {
155104
n.visit_children_with(self);
156105

crates/swc_ecma_lints/src/rules/no_dupe_args.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use std::collections::hash_map::Entry;
33
use rustc_hash::FxHashMap;
44
use swc_common::errors::HANDLER;
55
use swc_ecma_ast::*;
6-
use swc_ecma_utils::{
7-
for_each_binding_ident,
8-
parallel::{cpu_count, Parallel, ParallelExt},
9-
};
6+
use swc_ecma_utils::for_each_binding_ident;
107
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
118

129
use crate::rule::{visitor_rule, Rule};
@@ -18,14 +15,6 @@ pub fn no_dupe_args() -> Box<dyn Rule> {
1815
#[derive(Debug, Default)]
1916
struct NoDupeArgs;
2017

21-
impl Parallel for NoDupeArgs {
22-
fn create(&self) -> Self {
23-
Self
24-
}
25-
26-
fn merge(&mut self, _: Self) {}
27-
}
28-
2918
#[cold]
3019
fn error(first: &BindingIdent, second: &BindingIdent) {
3120
HANDLER.with(|handler| {
@@ -112,57 +101,15 @@ impl Visit for NoDupeArgs {
112101
f.visit_children_with(self);
113102
}
114103

115-
fn visit_class_members(&mut self, members: &[ClassMember]) {
116-
self.maybe_par(cpu_count(), members, |v, member| {
117-
member.visit_with(v);
118-
});
119-
}
120-
121104
fn visit_constructor(&mut self, f: &Constructor) {
122105
check!(&f.params);
123106

124107
f.visit_children_with(self);
125108
}
126109

127-
fn visit_expr_or_spreads(&mut self, n: &[ExprOrSpread]) {
128-
self.maybe_par(cpu_count(), n, |v, n| {
129-
n.visit_with(v);
130-
});
131-
}
132-
133-
fn visit_exprs(&mut self, exprs: &[Box<Expr>]) {
134-
self.maybe_par(cpu_count(), exprs, |v, expr| {
135-
expr.visit_with(v);
136-
});
137-
}
138-
139110
fn visit_function(&mut self, f: &Function) {
140111
check!(&f.params);
141112

142113
f.visit_children_with(self);
143114
}
144-
145-
fn visit_module_items(&mut self, items: &[ModuleItem]) {
146-
self.maybe_par(cpu_count(), items, |v, item| {
147-
item.visit_with(v);
148-
});
149-
}
150-
151-
fn visit_opt_vec_expr_or_spreads(&mut self, n: &[Option<ExprOrSpread>]) {
152-
self.maybe_par(cpu_count(), n, |v, n| {
153-
n.visit_with(v);
154-
});
155-
}
156-
157-
fn visit_prop_or_spreads(&mut self, n: &[PropOrSpread]) {
158-
self.maybe_par(cpu_count(), n, |v, n| {
159-
n.visit_with(v);
160-
});
161-
}
162-
163-
fn visit_stmts(&mut self, stmts: &[Stmt]) {
164-
self.maybe_par(cpu_count(), stmts, |v, stmt| {
165-
stmt.visit_with(v);
166-
});
167-
}
168115
}

0 commit comments

Comments
 (0)