Faster processing of array comparisons with constant offsets#3933
Faster processing of array comparisons with constant offsets#3933ondrejmirtes merged 3 commits intophpstan:2.1.xfrom
Conversation
|
This pull request has been marked as ready for review. |
|
|
||
| if ($originalExprType->equals($nativeType)) { | ||
| $newType = TypeCombinator::intersect($type, $originalExprType); | ||
| if ($newType->isConstantScalarValue()->yes() && $newType->equals($originalExprType)) { |
There was a problem hiding this comment.
I don't get it, why only for $newType->isConstantScalarValue()->yes()?
And: can we make it faster for the other return in this method too?
There was a problem hiding this comment.
I don't get it, why only for
$newType->isConstantScalarValue()->yes()?
I went with constant scalars as these matched best the slow case at hand
additionally there are types with weird equals-semantics like ...
$mixed->equals($error)=>true(becauseErrorType extends MixedType)- ObjectType
... for which tests start failing if we take the fast-pass without changing the scope
And: can we make it faster for the other return in this method too?
I can't think of a case where this would help
There was a problem hiding this comment.
These equals problems should be fixed, they might lead to other bugfixes as well.
|
Thank you! |
step debugging thru the example made me realize that most of the time we were adding the same constant types to the scope again. This PR detects this situation and does a fast exit to prevent unnecessary scope creations.
before this PR
after this PR
closes phpstan/phpstan#12800