Skip to content

Commit

Permalink
perf(linter): iterate over each rule only once
Browse files Browse the repository at this point in the history
  • Loading branch information
camchenry committed Oct 16, 2024
1 parent 389d261 commit eab9176
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,20 @@ impl Linter {
.rules
.iter()
.filter(|rule| rule.should_run(&ctx_host))
.map(|rule| (rule, Rc::clone(&ctx_host).spawn(rule)))
.collect::<Vec<_>>();
.map(|rule| (rule, Rc::clone(&ctx_host).spawn(rule)));

for (rule, ctx) in &rules {
let semantic = ctx_host.semantic();

for (rule, ref ctx) in rules.clone() {
rule.run_once(ctx);
}

let semantic = ctx_host.semantic();
for symbol in semantic.symbols().symbol_ids() {
for (rule, ctx) in &rules {
for (rule, ref ctx) in rules.clone() {
for symbol in semantic.symbols().symbol_ids() {
rule.run_on_symbol(symbol, ctx);
}
}

for node in semantic.nodes() {
for (rule, ctx) in &rules {
for node in semantic.nodes() {
rule.run(node, ctx);
}
}
Expand Down

0 comments on commit eab9176

Please sign in to comment.