1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Simplify php_sxe_count_elements_helper() by using non-destructive iterator reset

This commit is contained in:
Niels Dossche
2023-09-17 13:50:19 +02:00
parent fe98a16af7
commit 8f9626c0f7

View File

@@ -1873,15 +1873,9 @@ PHP_METHOD(SimpleXMLElement, __toString)
static zend_result php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long *count) /* {{{ */
{
xmlNodePtr node;
zval data;
*count = 0;
ZVAL_COPY_VALUE(&data, &sxe->iter.data);
ZVAL_UNDEF(&sxe->iter.data);
node = php_sxe_reset_iterator(sxe, 0);
xmlNodePtr node = php_sxe_reset_iterator_no_clear_iter_data(sxe, 0);
while (node)
{
@@ -1889,11 +1883,6 @@ static zend_result php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long
node = php_sxe_iterator_fetch(sxe, node->next, 0);
}
if (!Z_ISUNDEF(sxe->iter.data)) {
zval_ptr_dtor(&sxe->iter.data);
}
ZVAL_COPY_VALUE(&sxe->iter.data, &data);
return SUCCESS;
}
/* }}} */