Skip to content

Avoid unnecessary intersection in MutatingScope::filterBySpecifiedTypes#1536

Merged
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
herndlm:avoid-intersection-in-mutating-scope
Jul 22, 2022
Merged

Avoid unnecessary intersection in MutatingScope::filterBySpecifiedTypes#1536
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
herndlm:avoid-intersection-in-mutating-scope

Conversation

@herndlm
Copy link
Copy Markdown
Contributor

@herndlm herndlm commented Jul 21, 2022

While step-debugging something I saw that often $nativeType seems to be equal to $originalExprType. It was even identical. But the old code was ignoring that and intersecting both with the specified type. This change avoids this intersection (which could be complex for bigger constant arrays as we know) in case they are equal and it gets $originalExprType later only if needed (but I assume this doesn't change much).

It also moves this logic into a new addTypeToExpression method which kind of made sense to me since there's also a removeTypeFromExpression.

@herndlm herndlm force-pushed the avoid-intersection-in-mutating-scope branch from 3d4a805 to bc122c8 Compare July 21, 2022 20:58
@herndlm herndlm marked this pull request as ready for review July 21, 2022 21:07
@herndlm herndlm force-pushed the avoid-intersection-in-mutating-scope branch from bc122c8 to ae41cf2 Compare July 22, 2022 09:49
@ondrejmirtes ondrejmirtes merged commit 8aea239 into phpstan:1.8.x Jul 22, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@herndlm herndlm deleted the avoid-intersection-in-mutating-scope branch July 22, 2022 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants