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 5faeea2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,16 @@ impl Linter {
.map(|rule| (rule, Rc::clone(&ctx_host).spawn(rule)))
.collect::<Vec<_>>();

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 5faeea2

Please sign in to comment.