Skip to content

[DeadCode] Speed up RemoveUnusedVariableAssignRector by skipping deep body walk - #8605

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-remove-unused-assign
Oct 10, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-remove-unused-assign

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Perf

RemoveUnusedVariableAssignRector ran shouldSkip() first, which does a BetterNodeFinder::findFirst() deep walk over the whole method body (looking for include/compact/get_defined_vars) on every method, before knowing if there is anything removable.

resolvedAssignedVariablesByStmtPosition() only inspects top-level Expression(Assign) statements. When it returns nothing, there is no candidate to remove and the deep walk is wasted.

Reordered so the cheap candidate collection runs first; the full-body walk only runs when a removable assign actually exists. Behavior unchanged - shouldSkip still gates removal whenever candidates are present.

@TomasVotruba
TomasVotruba force-pushed the tv-perf-remove-unused-assign branch from 35bdc4c to 886932e Compare October 10, 2026 22:36
@TomasVotruba
TomasVotruba force-pushed the tv-perf-remove-unused-assign branch from bf55f95 to f8bda52 Compare October 10, 2026 22:44
@TomasVotruba
TomasVotruba merged commit 3ba1a81 into main Oct 10, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-remove-unused-assign branch October 10, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant