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>bb10
parent
8738d9a6a8
commit
011570285a
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue