summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-07-20 13:36:46 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-07-27 12:35:50 -0700
commit8738d9a6a861f79df83e563db41e8b95adeed14a (patch)
tree72be6ae6d4a42f1b37b4ef7a0cc7e35d9ce55162 /src/corelib/kernel/qvariant.cpp
parent27b10261398304978c3dc0166aad28d80c9b359e (diff)
QVariant: move the check for std::nullptr_t a bit up in customConstruct
Avoids having to do work after QMetaType::construct() returns. That can't get the tail-call optimization right now because it is a non- inline non-static member function, so the QMetaType must be spilled to the stack. Change-Id: I3859764fed084846bcb0fffd1703a3ffc723f43f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index f3c6305432..841c99bf49 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -218,7 +218,7 @@ static bool isValidMetaTypeForVariant(const QtPrivate::QMetaTypeInterface *iface
if (!iface || iface->size == 0)
return false;
- Q_ASSERT(!isVoid(iface)); // only void should have size 0
+ Q_ASSERT(!isInterfaceFor<void>(iface)); // only void should have size 0
if (!isCopyConstructible(iface) || !isDestructible(iface)) {
// all meta types must be copyable (because QVariant is) and
// destructible (because QVariant owns it)
@@ -243,11 +243,15 @@ static void customConstruct(const QtPrivate::QMetaTypeInterface *iface, QVariant
using namespace QtMetaTypePrivate;
Q_ASSERT(iface);
Q_ASSERT(iface->size);
- Q_ASSERT(!isVoid(iface));
+ Q_ASSERT(!isInterfaceFor<void>(iface));
Q_ASSERT(isCopyConstructible(iface));
Q_ASSERT(isDestructible(iface));
Q_ASSERT(copy || isDefaultConstructible(iface));
+ // need to check for nullptr_t here, as this can get called by fromValue(nullptr). fromValue() uses
+ // std::addressof(value) which in this case returns the address of the nullptr object.
+ d->is_null = !copy || isInterfaceFor<std::nullptr_t>(iface);
+
void *dst;
if (QVariant::Private::canUseInternalSpace(iface)) {
d->is_shared = false;
@@ -260,10 +264,6 @@ static void customConstruct(const QtPrivate::QMetaTypeInterface *iface, QVariant
// now ask QMetaType to construct for us
QMetaType(iface).construct(dst, copy);
-
- // need to check for nullptr_t here, as this can get called by fromValue(nullptr). fromValue() uses
- // std::addressof(value) which in this case returns the address of the nullptr object.
- d->is_null = !copy || QMetaType(iface) == QMetaType::fromType<std::nullptr_t>();
}
static void customClear(QVariant::Private *d)