Repository navigation
Blink: NoUnusedImports, avoid rescans per import - #277
Merged
Merged
Conversation
For each import, the rule looked up a map on every token, lowercased every comment again, and could scan to the end of the file for a comma. It now uses a cursor, lowercases each comment once, and stops at the end of the use statement. The output is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gnutix
force-pushed
the
perf/no-unused-imports
branch
from
November 4, 2026 17:37
941b1de to
40b294a
Compare
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: like upstream,
isImportUsedwalks the namespace once per import. On top of that, it did a map lookup on every token and lowercased every comment again for each import. AndparseDeclarationslooked for a,or{with no bound, so a plainuse Foo\Bar;scanned to the end of the file.Change: a cursor over the use statements, each comment lowercased once per file, and the search stops at the end of the statement.
Result: NoUnusedImports alone on a private 8.8k-file codebase: 1.36 s → 0.73 s of CPU.
Tests: existing tests pass, and the private codebase still has 0 diffs. On 28k files with 439 diffs, main and this branch give the same output.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1vvcRhpVMjWLC4U5j78Xp