summaryrefslogtreecommitdiff
path: root/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-09-04 11:31:52 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-09-20 10:51:02 +0000
commit9ec333d4bcb1f38537e79ad4e6b429972616daa9 (patch)
tree3c964b398d4e097e232b52d2b26b32c1b342c8e1 /src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp
parentc04e5e65be4f8a5da86968632aa866f5eecbcbc0 (diff)
downloadqtxmlpatterns-9ec333d4bcb1f38537e79ad4e6b429972616daa9.tar.gz
Diagonalize XsdValidatingInstanceReader::validateUniqueIdentityConstraint()
TargetNode::fieldsAreEqual() is symmetric, so diagonalize the nested loops to avoid both checking for identity as well as re-checking (A, B) if we already checked (B, A). Change-Id: I67668415b1f509e6119ea61b76213700e8b49b56 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp')
-rw-r--r--src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp b/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp
index 7cad16c..7cb925a 100644
--- a/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp
+++ b/src/xmlpatterns/schema/qxsdvalidatinginstancereader.cpp
@@ -973,17 +973,9 @@ bool XsdValidatingInstanceReader::validateUniqueIdentityConstraint(const XsdElem
// 4.1
const XsdSchemaSourceLocationReflection reflection(sourceLocation());
- QSetIterator<TargetNode> it(qualifiedNodeSet);
- while (it.hasNext()) {
- const TargetNode node = it.next();
- QSetIterator<TargetNode> innerIt(qualifiedNodeSet);
- while (innerIt.hasNext()) {
- const TargetNode innerNode = innerIt.next();
-
- if (node == innerNode) // do not compare with ourself
- continue;
-
- if (node.fieldsAreEqual(innerNode, m_namePool, m_context, &reflection)) {
+ for (auto it = qualifiedNodeSet.cbegin(), end = qualifiedNodeSet.cend(); it != end; ++it) {
+ for (auto jt = qualifiedNodeSet.cbegin(); jt != it; ++jt) {
+ if (it->fieldsAreEqual(*jt, m_namePool, m_context, &reflection)) {
error(QtXmlPatterns::tr("Non-unique value found for constraint %1.").arg(formatKeyword(constraint->displayName(m_namePool))));
return false;
}