diff --git a/ext/dom/element.c b/ext/dom/element.c index 348c669e1b4a2..7b8871c1bbe09 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -1023,11 +1023,6 @@ static void dom_remove_eliminated_ns(xmlNodePtr node, xmlNsPtr eliminatedNs) if (node->type == XML_ELEMENT_NODE) { dom_remove_eliminated_ns_single_element(node, eliminatedNs); - - if (node->children) { - node = node->children; - continue; - } } node = php_dom_next_in_tree_order(node, base); diff --git a/ext/dom/namespace_compat.c b/ext/dom/namespace_compat.c index 96fc90d08138b..dd5bc685b5412 100644 --- a/ext/dom/namespace_compat.c +++ b/ext/dom/namespace_compat.c @@ -439,11 +439,6 @@ PHP_DOM_EXPORT void php_dom_libxml_reconcile_modern(php_dom_libxml_ns_mapper *ns if (node->type == XML_ELEMENT_NODE) { php_dom_libxml_reconcile_modern_single_element_node(&ctx, node); - - if (node->children) { - node = node->children; - continue; - } } node = php_dom_next_in_tree_order(node, base); diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 7c7505015055f..3e90db31db7e3 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1762,11 +1762,6 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr basep, xmlNodePtr nodep, (*cur)++; } } - - if (nodep->children) { - nodep = nodep->children; - continue; - } } nodep = php_dom_next_in_tree_order(nodep, basep); diff --git a/ext/dom/xml_common.h b/ext/dom/xml_common.h index 2c9e1f9e413fd..ec555f3d0f128 100644 --- a/ext/dom/xml_common.h +++ b/ext/dom/xml_common.h @@ -91,6 +91,10 @@ static zend_always_inline php_dom_libxml_ns_mapper *php_dom_get_ns_mapper(dom_ob static zend_always_inline xmlNodePtr php_dom_next_in_tree_order(const xmlNode *nodep, const xmlNode *basep) { + if (nodep->type == XML_ELEMENT_NODE && nodep->children) { + return nodep->children; + } + if (nodep->next) { return nodep->next; } else { diff --git a/ext/dom/xml_document.c b/ext/dom/xml_document.c index fd5ded5b1a66d..c5ff51943e6f7 100644 --- a/ext/dom/xml_document.c +++ b/ext/dom/xml_document.c @@ -77,11 +77,6 @@ static void dom_mark_namespaces_as_attributes_too(php_dom_libxml_ns_mapper *ns_m while (node != NULL) { if (node->type == XML_ELEMENT_NODE) { php_dom_ns_compat_mark_attribute_list(ns_mapper, node); - - if (node->children) { - node = node->children; - continue; - } } node = php_dom_next_in_tree_order(node, NULL); diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 7dc040c1d234e..cbbb308927ca8 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -155,11 +155,6 @@ static void xsl_build_ns_map(xmlHashTablePtr table, xsltStylesheetPtr sheet, php xsl_add_ns_to_map(table, sheet, cur, prefix, ns->href); } } - - if (cur->children != NULL) { - cur = cur->children; - continue; - } } cur = php_dom_next_in_tree_order(cur, (const xmlNode *) doc);