Skip to content

Commit de54dd2

Browse files
committed
Update php_array_find implementation
1 parent 6eab59c commit de54dd2

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ext/standard/array.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6618,15 +6618,15 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z
66186618

66196619
ZVAL_COPY(&args[0], operand);
66206620

6621-
if (zend_call_function(&fci, &fci_cache) == SUCCESS) {
6621+
zend_result result = zend_call_function(&fci, &fci_cache);
6622+
if (EXPECTED(result == SUCCESS)) {
66226623
int retval_true;
66236624

66246625
retval_true = zend_is_true(&retval);
66256626
zval_ptr_dtor(&retval);
66266627

6627-
if (negate_condition) {
6628-
retval_true = !retval_true;
6629-
}
6628+
/* This negates the condition, if negate_condition is true. Otherwise it does nothing with `retval_true`. */
6629+
retval_true ^= negate_condition;
66306630

66316631
if (retval_true) {
66326632
if (result_value != NULL) {
@@ -6641,14 +6641,13 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z
66416641
zval_ptr_dtor(&args[1]);
66426642

66436643
return SUCCESS;
6644-
} else {
6645-
zval_ptr_dtor(&args[0]);
6646-
zval_ptr_dtor(&args[1]);
66476644
}
6648-
} else {
6649-
zval_ptr_dtor(&args[0]);
6650-
zval_ptr_dtor(&args[1]);
6645+
}
6646+
6647+
zval_ptr_dtor(&args[0]);
6648+
zval_ptr_dtor(&args[1]);
66516649

6650+
if (UNEXPECTED(result != SUCCESS)) {
66526651
return FAILURE;
66536652
}
66546653
} ZEND_HASH_FOREACH_END();

0 commit comments

Comments
 (0)