Skip to content

[DeadCode] Speed up RemoveAlwaysTrueIfConditionRector with single node traversal - #8653

Merged
TomasVotruba merged 2 commits into
mainfrom
perf-remove-always-true-single-traversal
Oct 14, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
perf-remove-always-true-single-traversal

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

shouldSkipExpr() runs on nearly every if node and did 6 separate subtree traversals - findInstancesOf() walks the tree once per type, so 5 node types plus a FuncCall pass meant 6 full walks before the expensive getNativeType() check.

Collapsed into a single short-circuiting findFirst() walk that bails on the first disqualifying node. Same semantics, one traversal instead of six.

Existing tests cover the behavior (29 pass).

@TomasVotruba
TomasVotruba merged commit cf8a2eb into main Oct 14, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-remove-always-true-single-traversal branch October 14, 2026 21:08
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