Unifty logic in QDomNodeListPrivate::forEachNode
All iterations through QDomNodeListPrivate were going through the forEachNode function with its own internal logic. The newly introduced iterator works with the similar logic but is written a bit more compact. Thus it makes sense to replace the forEachNode logic with internal functions of the iterator. Pick-to: 6.9 Change-Id: I22b7ae7a49e2bfaf84bede2fe0b45530a32f8d55 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
fc0e788d02
commit
b1c32afb91
@ -754,51 +754,13 @@ QDomNodePrivate *QDomNodeListPrivate::findPrevInOrder(QDomNodePrivate *p) const
|
|||||||
|
|
||||||
void QDomNodeListPrivate::forEachNode(qxp::function_ref<void(QDomNodePrivate*)> yield) const
|
void QDomNodeListPrivate::forEachNode(qxp::function_ref<void(QDomNodePrivate*)> yield) const
|
||||||
{
|
{
|
||||||
//TODO: simplify with findNextInList
|
|
||||||
if (!node_impl)
|
if (!node_impl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QDomNodePrivate* p = node_impl->first;
|
QDomNodePrivate *current = findNextInOrder(node_impl);
|
||||||
|
while (current && current != node_impl) {
|
||||||
if (tagname.isNull()) {
|
yield(current);
|
||||||
while (p) {
|
current = findNextInOrder(current);
|
||||||
yield(p);
|
|
||||||
p = p->next;
|
|
||||||
}
|
|
||||||
} else if (nsURI.isNull()) {
|
|
||||||
while (p && p != node_impl) {
|
|
||||||
if (p->isElement() && p->nodeName() == tagname) {
|
|
||||||
yield(p);
|
|
||||||
}
|
|
||||||
if (p->first)
|
|
||||||
p = p->first;
|
|
||||||
else if (p->next)
|
|
||||||
p = p->next;
|
|
||||||
else {
|
|
||||||
p = p->parent();
|
|
||||||
while (p && p != node_impl && !p->next)
|
|
||||||
p = p->parent();
|
|
||||||
if (p && p != node_impl)
|
|
||||||
p = p->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (p && p != node_impl) {
|
|
||||||
if (p->isElement() && p->name==tagname && p->namespaceURI==nsURI) {
|
|
||||||
yield(p);
|
|
||||||
}
|
|
||||||
if (p->first)
|
|
||||||
p = p->first;
|
|
||||||
else if (p->next)
|
|
||||||
p = p->next;
|
|
||||||
else {
|
|
||||||
p = p->parent();
|
|
||||||
while (p && p != node_impl && !p->next)
|
|
||||||
p = p->parent();
|
|
||||||
if (p && p != node_impl)
|
|
||||||
p = p->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user