Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[PropertyAccess] speed up accessing object properties#29999
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fbourigault commentedJan 27, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
As this provide almost identical performance boost (~ 20/30% perf improvement). I would prefer merging this and do further profiling to improve serializer performance. |
| self::VALUE =>$objectOrArray, | ||
| ]; | ||
| if (\is_object($objectOrArray) &&false ===strpos((string)$propertyPath,'.') &&false ===strpos((string)$propertyPath,'[')) { |
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.
| if (\is_object($objectOrArray) &&false ===strpos((string)$propertyPath,'.') &&false ===strpos((string)$propertyPath,'[')) { | |
| if (\is_object($objectOrArray) &&false ===strpbrk((string)$propertyPath,'.[')) { |
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.
Updated, though I wonder if usingstrcspn() and comparing that withstrlen() would be better in that it doesn't required to copy a string.
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.
According tohttps://blackfire.io/profiles/compare/f5b0113a-fcae-41cc-9b83-3bdd48c8bcf5/graph usingstrpbrk is faster thanstrcspn +strlen.
Uh oh!
There was an error while loading.Please reload this page.
fbourigault commentedJan 27, 2019
Here is a profile of this PR (with@ostrolucky suggestions ; single |
fabpot commentedJan 30, 2019
Thank you@xabbuh. |
…(xabbuh)This PR was merged into the 4.3-dev branch.Discussion----------[PropertyAccess] speed up accessing object properties| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#28926,#29405| License | MIT| Doc PR |I propose to improve the performance of the `ObjectNormalizer` by not adding a new interface to the PropertyAccess component, but by adding some shortcut for cases where we know that we do not need to perform all checks. The added benefit is that this will not only speed up the `ObjectNormalizer` class, but will be available for every consumer of the `PropertyAccessor` without having to adapt to a new API.TODO:- [ ] confirm that these changes indeed introduce the same benefit as#29405 doing an actual benchmarkCommits-------ef7876e speed up accessing object properties
Uh oh!
There was an error while loading.Please reload this page.
I propose to improve the performance of the
ObjectNormalizerby not adding a new interface to the PropertyAccess component, but by adding some shortcut for cases where we know that we do not need to perform all checks. The added benefit is that this will not only speed up theObjectNormalizerclass, but will be available for every consumer of thePropertyAccessorwithout having to adapt to a new API.TODO: