You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dbc4c09
Browse filesBrowse the repository at this point in the historyBrowse files
perf(bots): hoist per-call regex compilation into LazyLock statics
Hypatia expect_in_hot_path. Regex::new(<literal>).expect(..) was being called
inside function bodies, so the regex recompiled on every invocation of an
analyzer that runs per file. Hoisted to module-level LazyLock statics: compiled
once, on first use.
Touched 6 files across 3 crates:
accessibilitybot contrast.rs (6), css.rs (4->3), keyboard.rs (2)
finishingbot claims.rs (2), license.rs (1)
glambot accessibility.rs (3)
glambot additionally needed use regex::Regex; at module scope -- it was
function-scoped, which no longer reaches the hoisted statics. The now-redundant
function-local imports were removed.
Deliberately NOT touched: the 11 files whose expect() already sits inside a
LazyLock/OnceLock initialiser (they compile once already -- the rule is wrong
about those), and the expect() calls that are panic-on-error rather than
per-call compilation (a semaphore acquire, a post-insert lookup, benchmark
setup). Those need error handling or a rule fix, not caching.
Verified: cargo check exit 0 on all three crates.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments