From 5a9e93630e70c440877e2c349a864d54b1557dcb Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 27 Aug 2024 18:58:10 +0200 Subject: [PATCH] QXmlStream: actually make the (in)equality operators noexcept Do not use the getters, as they are not noexcept. While they could probably be made noexcept, we're too close to release to make a hasty change there. Directly access the data members instead. Found in API-review. Amends cd5dd8b95bbda1e9531af52c251ea926f125c8ea. Change-Id: Ic3a6b0f933956d57d2c3b4ebdd5ad40ec4736fb0 Reviewed-by: Thiago Macieira (cherry picked from commit 23784ec9d6eca9b138cd2528389e8150ebc66667) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/serialization/qxmlstream.h | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index d83fab7c8a..4f7ecd8cd9 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -78,10 +78,12 @@ private: friend bool comparesEqual(const QXmlStreamAttribute &lhs, const QXmlStreamAttribute &rhs) noexcept { - return (lhs.value() == rhs.value() - && (lhs.namespaceUri().isNull() ? (lhs.qualifiedName() == rhs.qualifiedName()) - : (lhs.namespaceUri() == rhs.namespaceUri() - && lhs.name() == rhs.name()))); + if (lhs.m_value != rhs.m_value) + return false; + if (lhs.m_namespaceUri.isNull()) + return lhs.m_qualifiedName == rhs.m_qualifiedName; + return lhs.m_namespaceUri == rhs.m_namespaceUri + && lhs.m_name == rhs.m_name; } Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamAttribute) }; @@ -140,7 +142,8 @@ private: friend bool comparesEqual(const QXmlStreamNamespaceDeclaration &lhs, const QXmlStreamNamespaceDeclaration &rhs) noexcept { - return (lhs.prefix() == rhs.prefix() && lhs.namespaceUri() == rhs.namespaceUri()); + return lhs.m_prefix == rhs.m_prefix + && lhs.m_namespaceUri == rhs.m_namespaceUri; } Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamNamespaceDeclaration) }; @@ -168,8 +171,8 @@ private: friend bool comparesEqual(const QXmlStreamNotationDeclaration &lhs, const QXmlStreamNotationDeclaration &rhs) noexcept { - return (lhs.name() == rhs.name() && lhs.systemId() == rhs.systemId() - && lhs.publicId() == rhs.publicId()); + return lhs.m_name == rhs.m_name && lhs.m_systemId == rhs.m_systemId + && lhs.m_publicId == rhs.m_publicId; } Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamNotationDeclaration) }; @@ -200,11 +203,11 @@ private: friend bool comparesEqual(const QXmlStreamEntityDeclaration &lhs, const QXmlStreamEntityDeclaration &rhs) noexcept { - return (lhs.name() == rhs.name() - && lhs.notationName() == rhs.notationName() - && lhs.systemId() == rhs.systemId() - && lhs.publicId() == rhs.publicId() - && lhs.value() == rhs.value()); + return lhs.m_name == rhs.m_name + && lhs.m_notationName == rhs.m_notationName + && lhs.m_systemId == rhs.m_systemId + && lhs.m_publicId == rhs.m_publicId + && lhs.m_value == rhs.m_value; } Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamEntityDeclaration) };