diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-08-07 04:21:49 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-08-07 04:21:49 (GMT) |
commit | 01f6bb95151f1852020aa7b149f33c49c1229a39 (patch) | |
tree | 5b425bff4343524eb0f0180aa04aa72a95af0f7b | |
parent | 281d3dc3cfff77c185912365130af36f8be632d3 (diff) | |
download | Qt-01f6bb95151f1852020aa7b149f33c49c1229a39.zip Qt-01f6bb95151f1852020aa7b149f33c49c1229a39.tar.gz Qt-01f6bb95151f1852020aa7b149f33c49c1229a39.tar.bz2 |
Store QObject*'s in the QVariant data structure
Rather than requiring an allocation of the "shared data" region,
QObject *'s should be stored directly in the data structure. This very
marginally, but measurably, improves QVariant performance.
Reviewed-by: Thiago Macieira
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 16 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 2b5ea0a..4166944 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -161,6 +161,9 @@ static void construct(QVariant::Private *x, const void *copy) case QMetaType::Float: x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f; break; + case QMetaType::QObjectStar: + x->data.o = copy ? *static_cast<QObject *const*>(copy) : 0; + break; case QVariant::LongLong: x->data.ll = copy ? *static_cast<const qlonglong *>(copy) : Q_INT64_C(0); break; @@ -257,6 +260,7 @@ static void clear(QVariant::Private *d) case QVariant::ULongLong: case QVariant::Double: case QMetaType::Float: + case QMetaType::QObjectStar: break; case QVariant::Invalid: case QVariant::UserType: @@ -326,6 +330,7 @@ static bool isNull(const QVariant::Private *d) case QVariant::Bool: case QVariant::Double: case QMetaType::Float: + case QMetaType::QObjectStar: break; } return d->is_null; @@ -419,6 +424,8 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return a->data.d == b->data.d; case QMetaType::Float: return a->data.f == b->data.f; + case QMetaType::QObjectStar: + return a->data.o == b->data.o; case QVariant::Date: return *v_cast<QDate>(a) == *v_cast<QDate>(b); case QVariant::Time: @@ -1048,6 +1055,9 @@ static void streamDebug(QDebug dbg, const QVariant &v) case QMetaType::Float: dbg.nospace() << qVariantValue<float>(v); break; + case QMetaType::QObjectStar: + dbg.nospace() << qVariantValue<QObject *>(v); + break; case QVariant::Double: dbg.nospace() << v.toDouble(); break; @@ -1361,7 +1371,7 @@ void QVariant::create(int type, const void *copy) QVariant::~QVariant() { - if (d.type > Char && d.type != QMetaType::Float && (!d.is_shared || !d.data.shared->ref.deref())) + if (d.type > Char && d.type != QMetaType::Float && d.type != QMetaType::QObjectStar && (!d.is_shared || !d.data.shared->ref.deref())) handler->clear(&d); } @@ -1377,7 +1387,7 @@ QVariant::QVariant(const QVariant &p) { if (d.is_shared) { d.data.shared->ref.ref(); - } else if (p.d.type > Char && p.d.type != QMetaType::Float) { + } else if (p.d.type > Char && p.d.type != QMetaType::Float && p.d.type != QMetaType::QObjectStar) { handler->construct(&d, p.constData()); d.is_null = p.d.is_null; } @@ -1733,7 +1743,7 @@ QVariant& QVariant::operator=(const QVariant &variant) if (variant.d.is_shared) { variant.d.data.shared->ref.ref(); d = variant.d; - } else if (variant.d.type > Char && variant.d.type != QMetaType::Float) { + } else if (variant.d.type > Char && variant.d.type != QMetaType::Float && variant.d.type != QMetaType::QObjectStar) { d.type = variant.d.type; handler->construct(&d, variant.constData()); d.is_null = variant.d.is_null; diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index a68939d..4489e95 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -358,6 +358,7 @@ class Q_CORE_EXPORT QVariant float f; qlonglong ll; qulonglong ull; + QObject *o; void *ptr; PrivateShared *shared; } data; |