Repository navigation
Build filter regexes interpreted instead of compiled [patch] - #174
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
A filter box makes a new pattern on every keystroke and matches it once, so RegexOptions.Compiled cost far more than it saved: about ten times the per-keystroke work and several times the memory of a full cache. The invalid-pattern fallback is now one shared, interpreted instance with the match timeout, instead of a newly compiled ".*" on every call. Fixes #144 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2nwQnKNnZqSnbuUxe
|
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.



Fixes #144
What changed
DoesMatchRegexno longer passesRegexOptions.Compiled. A filter box makes a new pattern on every keystroke and matches it once, so compiling each one to IL cost more than it saved.IgnoreCaseandCultureInvariantare unchanged, and so is the comment explaining them.RegexMatchAnythingused to be a method that built and compiled a new.*on every call. It is now a singlestatic readonlyinstance, interpreted and bounded byRegexMatchTimeout, in the same way asRegexMatchNothing.CreateFilterRegex, so tests can check the options directly. They don't have to read the shared cache, which parallel tests keep clearing.Matching behaviour is the same: the only differences are the options and the identity of the fallback instance.
Tests
FilterRegexesAreInterpretedNotCompiledruns under both sensitivities. It checks thatCompiledis absent, thatCultureInvariantis still set, thatIgnoreCasefollows the sensitivity, and that the 1 s timeout still applies.AnInvalidRegexFilterSharesOneInterpretedMatchAnythingInstancechecks that[and(unclosedreturn the same instance. That instance is not compiled, keeps the timeout, and still matches anything throughDoesMatchRegex.I didn't add a benchmark. The issue lists one as optional.
Generated by Claude Code