Skip to content

Commit 998997b

Browse files
authored
Remove nonsensical dom_node_children_valid() checks from parentnode.c (#14706)
Either these are for ParentNode, which are always valid parents that can hold children. Or these are for ChildNode, which always has a parent that can have children (by definition).
1 parent 58a6e55 commit 998997b

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

ext/dom/parentnode.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ zend_result dom_parent_node_first_element_child_read(dom_object *obj, zval *retv
3535
{
3636
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
3737

38-
xmlNodePtr first = NULL;
39-
if (dom_node_children_valid(nodep)) {
40-
first = nodep->children;
38+
xmlNodePtr first = nodep->children;
4139

42-
while (first && first->type != XML_ELEMENT_NODE) {
43-
first = first->next;
44-
}
40+
while (first && first->type != XML_ELEMENT_NODE) {
41+
first = first->next;
4542
}
4643

4744
if (!first) {
@@ -62,13 +59,10 @@ zend_result dom_parent_node_last_element_child_read(dom_object *obj, zval *retva
6259
{
6360
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
6461

65-
xmlNodePtr last = NULL;
66-
if (dom_node_children_valid(nodep)) {
67-
last = nodep->last;
62+
xmlNodePtr last = nodep->last;
6863

69-
while (last && last->type != XML_ELEMENT_NODE) {
70-
last = last->prev;
71-
}
64+
while (last && last->type != XML_ELEMENT_NODE) {
65+
last = last->prev;
7266
}
7367

7468
if (!last) {
@@ -90,16 +84,14 @@ zend_result dom_parent_node_child_element_count(dom_object *obj, zval *retval)
9084
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
9185

9286
zend_long count = 0;
93-
if (dom_node_children_valid(nodep)) {
94-
xmlNodePtr first = nodep->children;
95-
96-
while (first != NULL) {
97-
if (first->type == XML_ELEMENT_NODE) {
98-
count++;
99-
}
87+
xmlNodePtr first = nodep->children;
10088

101-
first = first->next;
89+
while (first != NULL) {
90+
if (first->type == XML_ELEMENT_NODE) {
91+
count++;
10292
}
93+
94+
first = first->next;
10395
}
10496

10597
ZVAL_LONG(retval, count);
@@ -704,10 +696,6 @@ static zend_result dom_child_removal_preconditions(const xmlNode *child, int str
704696
return FAILURE;
705697
}
706698

707-
if (!dom_node_children_valid(child->parent)) {
708-
return FAILURE;
709-
}
710-
711699
xmlNodePtr children = child->parent->children;
712700
if (!children) {
713701
php_dom_throw_error(NOT_FOUND_ERR, stricterror);

0 commit comments

Comments
 (0)