diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2012-01-09 11:36:03 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-16 02:00:30 +0100 |
commit | 1b23336a297681dc12700880540a5a8d31f146fe (patch) | |
tree | a9b3b0ed63d3d14b1741644a38cd87c0510a89cf /src | |
parent | 214e031d56714ba69ef929f1e763e243b393e460 (diff) |
Use static-less QMetaType API in QVariant.
This patch improves performance when constructing a custom type in
a QVariant by ~ 7-20% (instructions count) depending on the type size
and metatype attributes.
Change-Id: Ic2707ff5abd689b66e23c1794f111504bf9b3b01
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 4197fe9093..d0470ff796 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -787,7 +787,8 @@ const QVariant::Handler qt_dummy_variant_handler = { static void customConstruct(QVariant::Private *d, const void *copy) { - const uint size = QMetaType::sizeOf(d->type); + const QMetaType type(d->type); + const uint size = type.sizeOf(); if (!size) { d->type = QVariant::Invalid; return; @@ -795,11 +796,11 @@ static void customConstruct(QVariant::Private *d, const void *copy) // this logic should match with QVariantIntegrator::CanUseInternalSpace if (size <= sizeof(QVariant::Private::Data) - && (QMetaType::typeFlags(d->type) & QMetaType::MovableType)) { - QMetaType::construct(d->type, &d->data.ptr, copy); + && (type.flags() & QMetaType::MovableType)) { + type.construct(&d->data.ptr, copy); d->is_shared = false; } else { - void *ptr = QMetaType::create(d->type, copy); + void *ptr = type.create(copy); d->is_shared = true; d->data.shared = new QVariant::PrivateShared(ptr); } |