Access long value directly for call to count() in simplexml (#15278)

Because the signature is checked at compile time, we know that the only
possible return value (if there is no exception) is IS_LONG. So we can
avoid some work.
This commit is contained in:
Niels Dossche 2024-08-08 19:28:03 +02:00 committed by GitHub
parent 43def0af46
commit 746b1cf43e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1923,8 +1923,8 @@ static zend_result sxe_count_elements(zend_object *object, zend_long *count) /*
zval rv; zval rv;
zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv); zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv);
if (!Z_ISUNDEF(rv)) { if (!Z_ISUNDEF(rv)) {
*count = zval_get_long(&rv); ZEND_ASSERT(Z_TYPE(rv) == IS_LONG);
zval_ptr_dtor(&rv); *count = Z_LVAL(rv);
return SUCCESS; return SUCCESS;
} }
return FAILURE; return FAILURE;