perf: indexed loose rules by mandatory signatures - #180
Conversation
There was a problem hiding this comment.
💡 Codex Review
profanity/src/matchers/scan-guards.ts
Lines 394 to 395 in 02b5588
This treats every quantified negated character class as a separator even when it can consume letters. A valid loose dictionary rule such as b[^\s]*a therefore receives the mandatory ba signature, but it also matches bxa; scanning x resets the automaton, so no candidate start is recorded and the regex is never evaluated. Only skip classes proven to exclude \p{L} (with corresponding digit handling), or leave these rules on the compatibility fallback path.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the negated-class review finding in |
Summary
/iucase-fold matches in candidate indexing and keep negated classes that may consume letters off the mandatory-signature path.Validation
npm cinpm test -- tests/loose-candidates.spec.tsnpm run checknpm run benchmark:profanityonorigin/mainand this branchBenchmark Evidence
Baseline
origin/main:createProfanityFilter(): 7.5738 avg mscheck long clean: 0.9054 avg mscheck loose match: 0.0107 avg msanalyze long late match: 1.0083 avg mscensor long late match: 1.0452 avg msscanner check long clean: 0.8834 avg msscanner scan long late match: 1.0249 avg msThis branch:
createProfanityFilter(): 3.9225 avg msbuild loose signature index: 0.4446 avg mscheck long clean: 1.0387 avg mscheck loose match: 0.0130 avg msanalyze long late match: 1.1578 avg mscensor long late match: 1.1779 avg msscanner check long clean: 1.0158 avg msscanner scan long late match: 1.1815 avg msThe same-machine results show faster repeated filter construction and measured per-call candidate-accounting cost in the current corpus. The conservative index covers 121 of 148 built-in loose rules with 292 automaton nodes, 291 transitions, 343 outputs, and 34,682 tracked signature/bitset bytes.
Compatibility Notes
Closes #169
No publish, no merge, no tag/release.