Skip to content

[Renaming] Speed up RenameClassRector by deferring oldToNewTypes build - #8612

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-speedup-rename-class-defer-types
Oct 10, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-speedup-rename-class-defer-types

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

ClassRenamer::renameNode() is called for every FullyQualified, Name, Property, FunctionLike, Expression, ClassLike and If_ node across the whole codebase.

It ran createOldToNewTypes() as the first statement on every call, which does serialize($oldToNewClasses) + a hash of the full rename map. With large rename maps (Symfony/Doctrine/PHPUnit sets), that serialize+hash per node dominated the rule self-time in profiling.

The built $oldToNewTypes is only used inside the phpdoc branch. FullyQualified and Name nodes - the bulk - return early and never touch it. This defers the build to the point of use, so the serialize+hash runs only for phpdoc-bearing nodes.

No behavior change; tests unchanged and passing.

@TomasVotruba
TomasVotruba merged commit 3f34e5c into main Oct 10, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-speedup-rename-class-defer-types branch October 10, 2026 23:07
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