Skip to content

Conversation

iluuu1994
Copy link
Member

@iluuu1994 iluuu1994 commented Apr 4, 2023

Fixes GH-9775

As suggested in #9775 (comment).

I'm a little concerned about performance regression. Also, I think this is observable in min/max. These functions always return something, so it might as well return something that is consistent.

@iluuu1994 iluuu1994 requested a review from bwoebi April 4, 2023 16:28
@bwoebi
Copy link
Member

bwoebi commented Apr 4, 2023

I would change the two branches, given that the IS_OBJECT check will typically be consistently true or false, but result will be wildly unpredictable. The Bucket should be in L1 cache after the comparison.

@iluuu1994
Copy link
Member Author

iluuu1994 commented Apr 4, 2023

In that case we may just remove the result branch because once we've established an enum is involved it should always be uncomparable. Edit: Unless you mean type == IS_OBJECT && result == UNCOMPARABLE && class->ce_flags & ZEND_ACC_ENUM?

@bwoebi
Copy link
Member

bwoebi commented Apr 4, 2023

@iluuu1994 Sounds right.

But put the UNEXPECTED() around the IS_OBJECT comparison in particular, not the whole condition.

@iluuu1994 iluuu1994 force-pushed the enums-in-array_unique branch from 42fad69 to f260636 Compare April 4, 2023 17:12
{
return zend_compare(&f->val, &s->val);
int result = zend_compare(&f->val, &s->val);
// Special handling for enums
Copy link
Member Author

Choose a reason for hiding this comment

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

Before merging, add a comment that this is added for array_unique. Otherwise this may seem cryptic.

Copy link
Member

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@iluuu1994
Copy link
Member Author

Ugh, this doesn't handle references... They are usually unwrapped in zend_compare. I will need to fix that.

@iluuu1994 iluuu1994 force-pushed the enums-in-array_unique branch from f93ccc1 to a98e61e Compare April 5, 2023 09:54
@iluuu1994 iluuu1994 closed this in e8b8341 Apr 16, 2023
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.

4 participants