Skip to content

Conversation

takaram
Copy link

@takaram takaram commented Jan 1, 2025

Appending an empty generator is virtually a no-op, except that the generator gets consumed and is no longer available.
With this PR, AppendIterator::apend terminates early if its argument is an empty generator.

Comment on lines +108 to +115
static inline void zend_generator_ensure_initialized(zend_generator *generator) /* {{{ */
{
if (UNEXPECTED(Z_TYPE(generator->value) == IS_UNDEF) && EXPECTED(generator->execute_data) && EXPECTED(generator->node.parent == NULL)) {
zend_generator_resume(generator);
generator->flags |= ZEND_GENERATOR_AT_FIRST_YIELD;
}
}
/* }}} */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like exposing this in a header.

I would rather prefer creating a new API (e.g. zend_generator_is_empty), but considering you are trying to fix a bug in SPL it seems far more likely that SPL is doing something incorrect in the iterator code.

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.

2 participants