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 15, 2024
1 parent 389d261 commit 06000dc
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,18 @@ 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 {
rule.run_once(ctx);
}
for (rule, ctx) in rules {
rule.run_once(&ctx);

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

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

Expand Down

0 comments on commit 06000dc

Please sign in to comment.