QMetaType: inline isValid() and isRegistered()
isValid() is (or could be) used in a lot of places, so make it inline. One could effectively write it as: mt == QMetaType() And rely on comparesEqual() knowing that an invalid type cannot equal to a valid one. I'm inlining isRegistered() because it's a simple function. I chose to use the QT6_DECL_NEW_OVERLOAD technique instead of QT_CORE_INLINED_SINCE because the latter does not apply inlining to QtCore itself (aside from LTO). Change-Id: I0e727ab80c42d51867d0fffd2f9641bc88f926b1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
0568511e84
commit
0120d8ea1e
@ -1245,6 +1245,18 @@ QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData) noexcept
|
|||||||
#endif // QT_CORE_REMOVED_SINCE(6, 8)
|
#endif // QT_CORE_REMOVED_SINCE(6, 8)
|
||||||
|
|
||||||
#if QT_CORE_REMOVED_SINCE(6, 9)
|
#if QT_CORE_REMOVED_SINCE(6, 9)
|
||||||
|
#include "qmetatype.h"
|
||||||
|
|
||||||
|
bool QMetaType::isRegistered() const
|
||||||
|
{
|
||||||
|
return isRegistered(QT6_CALL_NEW_OVERLOAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QMetaType::isValid() const
|
||||||
|
{
|
||||||
|
return isValid(QT6_CALL_NEW_OVERLOAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "quuid.h"
|
#include "quuid.h"
|
||||||
|
|
||||||
|
@ -512,10 +512,6 @@ const char *QtMetaTypePrivate::typedefNameForType(const QtPrivate::QMetaTypeInte
|
|||||||
|
|
||||||
\sa isRegistered()
|
\sa isRegistered()
|
||||||
*/
|
*/
|
||||||
bool QMetaType::isValid() const
|
|
||||||
{
|
|
||||||
return d_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool QMetaType::isRegistered() const
|
\fn bool QMetaType::isRegistered() const
|
||||||
@ -527,10 +523,6 @@ bool QMetaType::isValid() const
|
|||||||
|
|
||||||
\sa qRegisterMetaType(), isValid()
|
\sa qRegisterMetaType(), isValid()
|
||||||
*/
|
*/
|
||||||
bool QMetaType::isRegistered() const
|
|
||||||
{
|
|
||||||
return d_ptr && d_ptr->typeId.loadRelaxed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int QMetaType::id() const
|
\fn int QMetaType::id() const
|
||||||
|
@ -457,8 +457,12 @@ public:
|
|||||||
explicit constexpr QMetaType(const QtPrivate::QMetaTypeInterface *d) : d_ptr(d) {}
|
explicit constexpr QMetaType(const QtPrivate::QMetaTypeInterface *d) : d_ptr(d) {}
|
||||||
constexpr QMetaType() = default;
|
constexpr QMetaType() = default;
|
||||||
|
|
||||||
|
#if QT_CORE_REMOVED_SINCE(6, 9)
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
bool isRegistered() const;
|
bool isRegistered() const;
|
||||||
|
#endif
|
||||||
|
constexpr bool isValid(QT6_DECL_NEW_OVERLOAD) const noexcept;
|
||||||
|
inline bool isRegistered(QT6_DECL_NEW_OVERLOAD) const noexcept;
|
||||||
void registerType() const
|
void registerType() const
|
||||||
{
|
{
|
||||||
// "register" is a reserved keyword
|
// "register" is a reserved keyword
|
||||||
@ -2640,6 +2644,16 @@ constexpr QMetaType QMetaType::fromType()
|
|||||||
return QMetaType(QtPrivate::qMetaTypeInterfaceForType<T>());
|
return QMetaType(QtPrivate::qMetaTypeInterfaceForType<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool QMetaType::isValid(QT6_IMPL_NEW_OVERLOAD) const noexcept
|
||||||
|
{
|
||||||
|
return d_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QMetaType::isRegistered(QT6_IMPL_NEW_OVERLOAD) const noexcept
|
||||||
|
{
|
||||||
|
return d_ptr && d_ptr->typeId.loadRelaxed();
|
||||||
|
}
|
||||||
|
|
||||||
constexpr qsizetype QMetaType::sizeOf() const
|
constexpr qsizetype QMetaType::sizeOf() const
|
||||||
{
|
{
|
||||||
return d_ptr ? d_ptr->size : 0;
|
return d_ptr ? d_ptr->size : 0;
|
||||||
|
@ -713,7 +713,7 @@ public:
|
|||||||
|
|
||||||
inline bool QVariant::isValid() const
|
inline bool QVariant::isValid() const
|
||||||
{
|
{
|
||||||
return d.type().isValid();
|
return d.type().isValid(QT6_CALL_NEW_OVERLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DATASTREAM
|
#ifndef QT_NO_DATASTREAM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user