Skip to content

Use zend_is_iterable #3146

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
Closed

Use zend_is_iterable #3146

wants to merge 1 commit into from

Conversation

carusogabriel
Copy link
Contributor

No description provided.

@KalleZ
Copy link
Member

KalleZ commented Feb 23, 2018

LGTM

@krakjoe
Copy link
Member

krakjoe commented Feb 24, 2018

I'm not sure what advantage there is of making this change ?

@carusogabriel
Copy link
Contributor Author

@krakjoe This was the last check for an iterable without the method, but also, isn’t good to standardize how we check them, so in the future, the maintenance would be easier?

@@ -2229,7 +2229,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
return xmlParam;
}

if (Z_TYPE_P(data) == IS_OBJECT && instanceof_function(Z_OBJCE_P(data), zend_ce_traversable)) {
if (Z_TYPE_P(data) == IS_OBJECT && zend_is_iterable(data)) {

Choose a reason for hiding this comment

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

Maybe it could be replaced by just if (zend_is_iterable(data)) and moving array check (L2290:2455) to top of this part?

Copy link
Contributor

@tpunt tpunt Feb 26, 2018

Choose a reason for hiding this comment

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

That's not going to work, since code in this branch requires only an object (zend_is_iterable will return true for arrays, too).

Edit: changing zend_is_iterable to not accept all iterables is going to be a bit of a misnomer, also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Closing this PR as performance and check were affected :(

Copy link
Member

Choose a reason for hiding this comment

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

@tpunt true, but it would fail even if it was an array as the first part of the conditional can never be true at that point, but I do agree we should evaluate each case before changing it, alternatively we can have some macros to cover common usages like the one in question here

@carusogabriel carusogabriel deleted the is-iterable branch February 26, 2018 19:09
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