-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster EnumCaseObjectType->describe() #3208
Conversation
This pull request has been marked as ready for review. |
do you think we are fast enough to add a regression test for the bug and call it a day? |
src/Type/Enum/EnumCaseObjectType.php
Outdated
if (!array_key_exists($value, $this->descriptions)) { | ||
$this->descriptions[$value] = sprintf('%s::%s', parent::describe($level), $this->enumCaseName); | ||
} | ||
return $this->descriptions[$value]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to cache this in the parent instead? In ObjectType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it also works. it makes the repro 0,2-0,3 seconds slower though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved the cache into ObjectType.
feel free to close this PR, in case it no longer serves a purpose.
FYI I have a local branch where the reproduction takes zero zero nothing seconds, I "just" need to make it fully work. So any further optimizations from you that shave off percents from the time are in the negligible returns territory. Stay tuned! :) |
Thats great news 💪 |
@staabm I'm going to test it after my change. The previous PRs made sense on their own, but here we are adding caches (which means more memory consumed) so let's wait if it's still worth it. |
repro of phpstan/phpstan#11263 before this PR
after this PR: