perf: reused prepared input across scanners and profiles - #179
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
npm cinpm test -- tests/prepared-input.spec.ts tests/scanner.spec.ts tests/multilanguage-filter.spec.ts tests/normalization.spec.ts tests/english-language-pack.spec.ts tests/api.spec.tsnpm run checknpm run benchmark:profanityBenchmark Evidence
Baseline
origin/main:createProfanityFilter(): 7.3146 avg msThis branch:
createProfanityFilter(): 7.5875 avg msWithin the final branch run, reused versus public-fallback preparation measured 0.5373 vs 0.6136 avg ms for long-clean checks, 0.3735 vs 0.5746 for matching checks, 0.4670 vs 0.5055 for analysis, 0.5304 vs 0.6666 for censoring, 0.4522 vs 0.4715 for scanner checks, and 0.4599 vs 0.5113 for scanner scans. Filter-construction cost remains visible, and the documentation directs consumers to reuse constructed filters.
Compatibility Notes
@textfilters/corecontracts are unchanged; the prepared capability remains package-internal.check()andanalyze()fallback, and missing, partial, or conflicting hints do not change matching behavior.check(),analyze(),censor(), scanner ranges, streaming order, legacy metadata ordering, profile provenance, taxonomy metadata, runtime mutation isolation, and UTF-16 offsets remain compatible.Closes #173
No publish, no merge, no tag/release.