From 746b1cf43ec35c1baa874709b17cd8b9af562c24 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:28:03 +0200 Subject: [PATCH] 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. --- ext/simplexml/simplexml.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index df3af01de39..8a12d430d47 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1923,8 +1923,8 @@ static zend_result sxe_count_elements(zend_object *object, zend_long *count) /* zval rv; zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv); if (!Z_ISUNDEF(rv)) { - *count = zval_get_long(&rv); - zval_ptr_dtor(&rv); + ZEND_ASSERT(Z_TYPE(rv) == IS_LONG); + *count = Z_LVAL(rv); return SUCCESS; } return FAILURE;