summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/quuid.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-06-27 12:24:30 +0200
committerIvan Solovev <ivan.solovev@qt.io>2024-08-30 21:35:31 +0200
commit81d31d2760c82a52aab1e23caae795abbaf55c01 (patch)
tree098df2998f1c1672d28e2a61d3fdcd1e4e757fab /src/corelib/plugin/quuid.cpp
parent637fcc69c87352c21658fea1083e93786f64fc37 (diff)
QUuid: make more methods constexpr
Use QT6_{DECL,CALL}_NEW_OVERLOAD mechanism to provide new constexpr overloads for isNull(), variant(), and version(). Move the old methods into removed_api.cpp Use this as an opportunity to optimize the implementaiton of the methods. Also add compile-time checks to the tests. It turns out that QNX compiler fails to compile the default QUuid::isNull() implementation in constexpr context, so rewrite it using a loop. Change-Id: Ia23c81194ea27b369f00ce73b016695600187e46 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin/quuid.cpp')
-rw-r--r--src/corelib/plugin/quuid.cpp30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index af7c07d23e6..3dcfa1faf2c 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -823,15 +823,11 @@ QDataStream &operator>>(QDataStream &s, QUuid &id)
#endif // QT_NO_DATASTREAM
/*!
+ \fn bool QUuid::isNull() const
+
Returns \c true if this is the null UUID
{00000000-0000-0000-0000-000000000000}; otherwise returns \c false.
*/
-bool QUuid::isNull() const noexcept
-{
- return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 &&
- data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 &&
- data1 == 0 && data2 == 0 && data3 == 0;
-}
/*!
\enum QUuid::Variant
@@ -875,17 +871,6 @@ bool QUuid::isNull() const noexcept
\sa version()
*/
-QUuid::Variant QUuid::variant() const noexcept
-{
- if (isNull())
- return VarUnknown;
- // Check the 3 MSB of data4[0]
- if ((data4[0] & 0x80) == 0x00) return NCS;
- else if ((data4[0] & 0xC0) == 0x80) return DCE;
- else if ((data4[0] & 0xE0) == 0xC0) return Microsoft;
- else if ((data4[0] & 0xE0) == 0xE0) return Reserved;
- return VarUnknown;
-}
/*!
\fn QUuid::Version QUuid::version() const
@@ -896,17 +881,6 @@ QUuid::Variant QUuid::variant() const noexcept
\sa variant()
*/
-QUuid::Version QUuid::version() const noexcept
-{
- // Check the 4 MSB of data3
- Version ver = (Version)(data3>>12);
- if (isNull()
- || (variant() != DCE)
- || ver < Time
- || ver > Sha1)
- return VerUnknown;
- return ver;
-}
/*!
\fn bool QUuid::operator<(const QUuid &lhs, const QUuid &rhs)