Repository navigation
Blink: let rules skip files without their trigger - #288
Merged
Merged
Conversation
Every write to the stream now changes its version. Three rules share one symbol scan while the file is unchanged, and eight rules skip a second render when nothing changed. The output is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A per-file index records the token kinds and words a file holds. A rule can implement IsCandidate, like PHP-CS-Fixer's isCandidate, and the runner skips it on files that cannot concern it. The output is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gnutix
force-pushed
the
perf/rule-candidates
branch
from
November 4, 2026 17:38
e477802 to
f6b3363
Compare
Member
|
Nice speed improvement! I think we should be able to get under 2 secs on such a project |
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.
Stacked on #279 (it uses
Stream.Memo): please merge that one first. Until then this diff also shows #279's commit.Problem: many rules look for a word (
sprintf,switch,null…) or a docblock that most files don't have, but still walk every token of every file to find out. PHP-CS-Fixer avoids this withisCandidate().Change:
Stream.Index(): built once per file, cached withStream.Memo. It holds the token kinds present, and the lowercased words in a Bloom filter. It can say "present" for an absent word, never the reverse. A non-ASCII word makes every word "present", because case folding maps some non-ASCII letters to ASCII ones.fixer.Candidate: an optionalIsCandidate(*Stream) bool. The runner skipsFixandErrorswhen it's false. Fixers without it, includingblink/extendones, run as before.Fix:applyToDocblocks,streamHas*,phpUnitTestClasses) check the index first, which helps about 30 more rules.declare,use,class…), punctuation, text inside docblocks, whitespace rules.Result: on a private 8.8k-file codebase, the 72 rules this touches: 5.91 s → 4.38 s of CPU. FunctionToConstant 140 → 5 ms, EregToPreg 139 → 6 ms. Building the index costs about 1%.
Tests:
SprintF,__Line__…).TestMainchecks that no rule rules out a source its own tests fix.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1vvcRhpVMjWLC4U5j78Xp