Skip to content

[perf] Speed up DeadCode rules with lazy docblock/walk and instanceof guard before scope type lookup - #8668

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-dc-lazy-and-instanceof-hoist
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-dc-lazy-and-instanceof-hoist

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Performance refactor of 3 rules. No behavior change - all fixtures pass unchanged.

  • RemoveUnusedPromotedPropertyRector - the constructor docblock is now parsed lazily, only when a promoted property is actually being removed, so constructors with no removable promoted property no longer parse their docblock.
  • RemoveRedundantTypeCheckRector - in both refactorBooleanOr() and refactorBooleanAnd(), the cheap BooleanNot / FuncCall instanceof check now runs before isNonTypedFromParam() (a scope type lookup).
  • RemoveDefaultValueFromAssignedPropertyRector - hasEarlyReturn() (a constructor subtree walk) is now evaluated lazily, only once a property is actually eligible for its default to be removed; it is cached, so classes with no eligible property skip the walk entirely.

Reordering is safe: the moved instanceof checks are side-effect-free bail conditions, and each lazily-computed value is created before its first use and is constant for the node.

@TomasVotruba
TomasVotruba enabled auto-merge (squash) October 15, 2026 19:35
@TomasVotruba
TomasVotruba merged commit c347182 into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-dc-lazy-and-instanceof-hoist branch October 15, 2026 19:37
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