summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Rauter <[email protected]>2025-01-14 14:20:55 +0100
committerMatthias Rauter <[email protected]>2025-02-10 17:33:23 +0100
commitb1c32afb914a8dda0b1b38bf9d85c1c316b27cf1 (patch)
tree132714592f938167a41badc1fc05d366adcb2a11
parentfc0e788d029beac251fda40650154fc6865e1649 (diff)
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 <[email protected]>
-rw-r--r--src/xml/dom/qdom.cpp46
1 files changed, 4 insertions, 42 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 8259da2f1cb..93c0f85c7c5 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -754,51 +754,13 @@ QDomNodePrivate *QDomNodeListPrivate::findPrevInOrder(QDomNodePrivate *p) const
void QDomNodeListPrivate::forEachNode(qxp::function_ref<void(QDomNodePrivate*)> yield) const
{
- //TODO: simplify with findNextInList
if (!node_impl)
return;
- QDomNodePrivate* p = node_impl->first;
-
- if (tagname.isNull()) {
- while (p) {
- 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;
- }
- }
+ QDomNodePrivate *current = findNextInOrder(node_impl);
+ while (current && current != node_impl) {
+ yield(current);
+ current = findNextInOrder(current);
}
}