Repository navigation
[perf] Check method name before type inference in DBAL/ORM method call rules - #536
Merged
Merged
Conversation
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.
What
Two
MethodCallrules ranisObjectType()(type inference) on the caller before comparing the method name, so the expensive type resolution ran on every method call in a file - including the overwhelming majority whose name is none of the rule's target methods and bail anyway.CastDoctrineExprToStringRector- checks the targetExprmethod name before theQUERY_EXPRtype check.ReplaceFetchAllMethodCallRector- bails on any name other thanfetchAll/fetchArray/fetchColumnbefore the twoisObjectType()checks (all sub-branches only act on those names).Pure reorder - both conditions are still ANDed, only the order flips.
Numbers
Micro bench (
bench/cast_doctrine_expr_name_guard_bench.php, shipped here), refactor() over 300 non-matching method calls, 200 repeats, CPU (user+sys):~5.7x on the common bail path. Full test suite stays green (306 tests).