Skip to content

Blink: NoUnusedImports, avoid rescans per import - #277

Merged
TomasVotruba merged 1 commit into
ecsphp:mainfrom
gnutix:perf/no-unused-imports
Nov 4, 2026
Merged

TomasVotruba merged 1 commit into
ecsphp:mainfrom
gnutix:perf/no-unused-imports

Conversation

@gnutix

@gnutix gnutix commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem: like upstream, isImportUsed walks 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. And parseDeclarations looked for a , or { with no bound, so a plain use 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

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
gnutix force-pushed the perf/no-unused-imports branch from 941b1de to 40b294a Compare November 4, 2026 17:37
@gnutix gnutix changed the title Blink: NoUnusedImports, drop three per-import rescans Blink: NoUnusedImports, avoid rescans per import Nov 4, 2026
@TomasVotruba
TomasVotruba merged commit 59ca901 into ecsphp:main Nov 4, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants