-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Support enums in array_unique #11015
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
Conversation
I would change the two branches, given that the IS_OBJECT check will typically be consistently true or false, but |
In that case we may just remove the |
@iluuu1994 Sounds right. But put the UNEXPECTED() around the IS_OBJECT comparison in particular, not the whole condition. |
42fad69
to
f260636
Compare
ext/standard/array.c
Outdated
@@ -345,7 +345,24 @@ static zend_always_inline int php_array_key_compare_string_locale_unstable_i(Buc | |||
|
|||
static zend_always_inline int php_array_data_compare_unstable_i(Bucket *f, Bucket *s) /* {{{ */ | |||
{ | |||
return zend_compare(&f->val, &s->val); | |||
int result = zend_compare(&f->val, &s->val); | |||
// Special handling for enums |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Ugh, this doesn't handle references... They are usually unwrapped in |
f93ccc1
to
a98e61e
Compare
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.