Repository navigation
[perf] Skip ancestor reflection when no parent:: call to trim - #8707
Merged
Merged
Conversation
…veArgumentFromDefaultParentCallRector
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.
RemoveArgumentFromDefaultParentCallRectorsubscribes toClass_. For every class that extends a parent it resolved the class reflection and walkedgetAncestors()- native reflection over the whole ancestor chain - before checking whether the class body even contains aparent::call to trim. A subclass that never callsparent::(the common case) paid for that ancestor lookup only to find nothing to do.A cheap AST pre-scan (
hasParentStaticCall) now bails beforeresolveClassReflection()/getAncestors()when no non-private, non-abstract method body holds aparent::static call. It mirrors the guards the main loop already applies, so it never skips a class the rule would have changed.Behavior unchanged - all 5 fixtures pass.
A standalone bench is included (
bench/remove_argument_from_default_parent_call_bench.php), drivingrefactor()over 150 subclasses that extend a parent but never callparent::. CPU per call, averaged, two runs each:~3x faster on that hot path. Run
php bench/remove_argument_from_default_parent_call_bench.phpon each branch to reproduce.