Skip to content

Preserve profanity scanner check fast path#145

Merged
alyldas merged 1 commit into
mainfrom
issue-143-strict-fast-path
Jul 1, 2026
Merged

Preserve profanity scanner check fast path#145
alyldas merged 1 commit into
mainfrom
issue-143-strict-fast-path

Conversation

@alyldas

@alyldas alyldas commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep the profanity scanner check path allocation-aware for empty hinted input.
  • Add package-local ProfanityScanHints aligned with shared text hints while keeping every hint optional.
  • Return early from package-owned scanner.check() when textLength: 0 is provided.
  • Preserve external fallback filter behavior for hinted empty input.
  • Add regression coverage and benchmark evidence for clean, Cyrillic, obfuscation, and late-match paths.

Validation

  • npm ci with a temporary npm cache
  • npm run check with a temporary npm cache
  • npm run benchmark:profanity with a temporary npm cache

Benchmark Evidence

Baseline origin/main:

  • createProfanityFilter(): 8.0078 avg ms
  • check short clean: 0.0274 avg ms
  • check cyrillic clean: 0.0616 avg ms
  • check long clean: 4.3929 avg ms
  • check short match: 0.0037 avg ms
  • check loose match: 0.0222 avg ms
  • check long late match: 0.2657 avg ms
  • scanner check short clean: 0.0245 avg ms
  • scanner check short match: 0.0029 avg ms
  • scanner scan short match: 0.0326 avg ms
  • analyze short match: 0.0325 avg ms
  • censor short match: 0.0330 avg ms
  • check minSeverity high: 0.0030 avg ms

This branch:

  • createProfanityFilter(): 8.2580 avg ms
  • check short clean: 0.0261 avg ms
  • check cyrillic clean: 0.0590 avg ms
  • check long clean: 4.4114 avg ms
  • check short match: 0.0037 avg ms
  • check loose match: 0.0217 avg ms
  • check long late match: 0.2603 avg ms
  • scanner check short clean: 0.0243 avg ms
  • scanner check hinted empty: 0.0000 avg ms
  • scanner check short match: 0.0029 avg ms
  • scanner scan short match: 0.0344 avg ms
  • analyze short match: 0.0393 avg ms
  • censor short match: 0.0343 avg ms
  • check minSeverity high: 0.0032 avg ms

The runtime change adds a hinted empty-input guard for package-owned scanner checks; scanner matching behavior and dictionary contents are unchanged.

Compatibility Notes

  • Public filter APIs are unchanged.
  • ProfanityScanInput.hints remains optional, and existing textLength / hasNonAscii callers remain compatible.
  • No dictionary entries were added or changed.

Closes #143

BEGIN_COMMIT_OVERRIDE
fix: preserve profanity scanner check fast path
END_COMMIT_OVERRIDE

@alyldas alyldas merged commit 1abf767 into main Jul 1, 2026
4 checks passed
@alyldas alyldas deleted the issue-143-strict-fast-path branch July 1, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Split strict fast path from loose candidate matching

1 participant