Skip to content

array_find: Remove unnecessary refcounting #17536

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

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -6622,14 +6622,14 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z
if (!str_key) {
ZVAL_LONG(&args[1], num_key);
} else {
ZVAL_STR_COPY(&args[1], str_key);
ZVAL_STR(&args[1], str_key);
}

ZVAL_COPY(&args[0], operand);
ZVAL_COPY_VALUE(&args[0], operand);

zend_result result = zend_call_function(&fci, &fci_cache);
if (EXPECTED(result == SUCCESS)) {
int retval_true;
bool retval_true;

retval_true = zend_is_true(&retval);
zval_ptr_dtor(&retval);
Expand All @@ -6646,16 +6646,10 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z
ZVAL_COPY(result_key, &args[1]);
}

zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);

return SUCCESS;
}
}

zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);

if (UNEXPECTED(result != SUCCESS)) {
return FAILURE;
}
Expand Down
Loading