Skip to content

Optimize out no-op yield from statements #5679

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

Closed
wants to merge 1 commit into from

Conversation

TysonAndre
Copy link
Contributor

If the array is empty, then I'd expect that the generator is never left,
and that can be converted to a no-op and the return value would always be null.

Make yield from []; as efficient as if (false) { yield null; }
when opcache's sccp pass is enabled.

@nikic
Copy link
Member

nikic commented Jun 7, 2020

i386 fails with:

005+ 0000 INIT_FCALL 0 64 string("test")
005- 0000 INIT_FCALL 0 96 string("test")
009+ 0004 INIT_FCALL 1 64 string("var_export")
009- 0004 INIT_FCALL 1 96 string("var_export")

If the array is empty, then I'd expect that the generator is never left,
and that can be converted to a no-op and the return value would always be `null`.

Make `yield from [];` as efficient as `if (false) { yield null; }`
when opcache's sccp pass is enabled.
@php-pulls php-pulls closed this in 543684e Jun 8, 2020
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