Repository navigation
[perf] Look up class rename by name in RenameClassRector const-fetch guard - #8735
Merged
Merged
Conversation
…guard shouldSkipClassConstFetchForMissingConstantName() scanned the whole configured rename map with isName() per fully-qualified class-const fetch node. A node has a single name and the map is keyed by old class, so this is a direct hash lookup - the same lookup the rename itself already does. Upgrade sets configure thousands of class renames, so the scan was a per-node linear cost over every class-const fetch. bench/rename_class_const_fetch_lookup_bench.php (500 renames, 150 non-matching const fetches): 1271.9 -> 2.0 us/call.
This was referenced Oct 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same shape as #8734, applied to the class-rename path.
RenameClassRector::shouldSkipClassConstFetchForMissingConstantName()scanned the whole configured rename map, runningisName()on each entry per fully-qualified class-const fetch node. But a node has a single name and the map is keyed by old class, so the entry can be found with a direct hash lookup - the same lookupClassRenameralready uses for the rename itself. Upgrade sets configure thousands of class renames, so the scan was a per-node linear cost over every class-const fetch, andisName()on a fully-qualified node is not cheap.Behaviour
Equivalent:
hasClass()above already uses$fullyQualified->toString(), and the actual rename matches by the same case-sensitive key, so a canonical-FQCN map resolves identically. Covered byskip_rename_target_interface_class_const_fetch_not_found.php.inc.Numbers
bench/rename_class_const_fetch_lookup_bench.php(500 renames, 150 non-matching const fetches, CPU time):Scales with the configured rename-map size. Full
rules-tests/Renaming(107 tests) green, PHPStan and ECS clean.