Repository navigation
Blink: classify array brackets in one pass - #287
Merged
Merged
Conversation
Some array rules walked back to the enclosing bracket for every "[", which is quadratic in a large array. They now follow the brackets in one forward pass, or use a short backward scan. The output is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gnutix
force-pushed
the
perf/array-notation-enclosing
branch
from
November 4, 2026 17:37
0dfcabd to
95ad218
Compare
Member
|
Thanks 👍 |
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.
Problem: for every
[, TrailingCommaInMultiline, ArraySyntax/ListSyntax (syntax=long), WhitespaceAfterCommaInArray and StatementIndentation ask which bracket encloses it.arrayNotationEnclosingandarrayNotationInForeachHeadanswer by scanning back to that bracket, so a large array is quadratic.Change:
arrayNotationTracker).arrayNotationToLongwalk backward. They try a backward scan of at most 256 tokens, and only when that isn't enough run one forward pass over the file (arrayNotationScan).Result: a 40k-token file with one large array: 1.09 s → 0.19 s with all rules. On a private 8.8k-file codebase, TrailingCommaInMultiline: 630 → 330 ms.
Tests: a new test compares the new code with the backward scans at every index of 20,000 random token streams. Existing tests pass, and the private codebase still has 0 diffs. On 28k files, main and this branch give the same output for each of these rules, and for all rules together.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1vvcRhpVMjWLC4U5j78Xp