summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-07-20 13:55:24 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-07-27 12:35:50 -0700
commit011570285a22661e5d353cb8527392de01981a78 (patch)
treef572200db815d7e8693481547ebdfe9e96157483 /src/corelib/kernel/qvariant.cpp
parent8738d9a6a861f79df83e563db41e8b95adeed14a (diff)
QVariant: use QtMetaTypePrivate directly instead of QMetaType
This suppresses a few duplicated checks that both QMetaType and QVariant has (and QVariant's are stricter), and allows for customConstruct() to perform a tail-call optimization, if it doesn't get inlined. Change-Id: I3859764fed084846bcb0fffd1703a503ffb01f8f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 841c99bf49..9d89178428 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -256,6 +256,8 @@ static void customConstruct(const QtPrivate::QMetaTypeInterface *iface, QVariant
if (QVariant::Private::canUseInternalSpace(iface)) {
d->is_shared = false;
dst = &d->data;
+ if (!copy && !iface->defaultCtr)
+ return; // trivial default constructor, we've already memset
} else {
d->data.shared = QVariant::PrivateShared::create(iface);
d->is_shared = true;
@@ -263,17 +265,18 @@ static void customConstruct(const QtPrivate::QMetaTypeInterface *iface, QVariant
}
// now ask QMetaType to construct for us
- QMetaType(iface).construct(dst, copy);
+ construct(iface, dst, copy);
}
static void customClear(QVariant::Private *d)
{
- if (!d->typeInterface())
+ const QtPrivate::QMetaTypeInterface *iface = d->typeInterface();
+ if (!iface)
return;
if (!d->is_shared) {
- d->type().destruct(d->data.data);
+ QtMetaTypePrivate::destruct(iface, d->data.data);
} else {
- d->type().destruct(d->data.shared->data());
+ QtMetaTypePrivate::destruct(iface, d->data.shared->data());
QVariant::PrivateShared::free(d->data.shared);
}
}