Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache][String] Don't use is_iterable() in perf-critical code paths #46017

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

Merged
merged 1 commit into from
Apr 12, 2022

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 6.1
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

This is 5 times faster than calling is_iterable()

Partially reverting #45978 /cc @fancyweb FYI.

@stof
Copy link
Member

stof commented Apr 12, 2022

The difference is probably because \is_array is a compiler-optimized function (and instanceof is a dedicated opcode) while is_iterable is not compiler-optimized.

@nicolas-grekas nicolas-grekas merged commit efc974d into symfony:6.1 Apr 12, 2022
@nicolas-grekas nicolas-grekas deleted the is_iter branch April 12, 2022 14:58
@derrabus
Copy link
Member

Indeed: https://3v4l.org/VLMNB/vld

Anyone up for patching PHP to make is_iterable() compiler-optimized? I find it kind of surprising that it is not. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants