diff options
author | Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> | 2014-10-22 15:17:41 +0200 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@digia.com> | 2014-10-31 13:39:33 +0100 |
commit | f0b7abf2ef723432b387dfc5e0706675a9447133 (patch) | |
tree | e1fb9a884ac259e127e9e098189da3cd1c2eadfd /src/corelib/kernel/qvariant.h | |
parent | e76b0c05f2c0f0376157aa1ef5fdc5d718248d98 (diff) |
Lower QVariant::userType call count
We know that type id can't be changed, let pass this information to the
compiler.
Change-Id: I105b460417288b84250a954571c247608976f8f7
Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.h')
-rw-r--r-- | src/corelib/kernel/qvariant.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 57e0523f7c..7dce813bb5 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -703,14 +703,15 @@ namespace QtPrivate { { static QSequentialIterable invoke(const QVariant &v) { - if (v.userType() == qMetaTypeId<QVariantList>()) { + const int typeId = v.userType(); + if (typeId == qMetaTypeId<QVariantList>()) { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QVariantList*>(v.constData()))); } - if (v.userType() == qMetaTypeId<QStringList>()) { + if (typeId == qMetaTypeId<QStringList>()) { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QStringList*>(v.constData()))); } #ifndef QT_BOOTSTRAPPED - if (v.userType() == qMetaTypeId<QByteArrayList>()) { + if (typeId == qMetaTypeId<QByteArrayList>()) { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QByteArrayList*>(v.constData()))); } #endif @@ -722,10 +723,11 @@ namespace QtPrivate { { static QAssociativeIterable invoke(const QVariant &v) { - if (v.userType() == qMetaTypeId<QVariantMap>()) { + const int typeId = v.userType(); + if (typeId == qMetaTypeId<QVariantMap>()) { return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantMap*>(v.constData()))); } - if (v.userType() == qMetaTypeId<QVariantHash>()) { + if (typeId == qMetaTypeId<QVariantHash>()) { return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantHash*>(v.constData()))); } return QAssociativeIterable(v.value<QtMetaTypePrivate::QAssociativeIterableImpl>()); @@ -736,7 +738,8 @@ namespace QtPrivate { { static QVariantList invoke(const QVariant &v) { - if (QtMetaTypePrivate::isBuiltinSequentialType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) { + const int typeId = v.userType(); + if (QtMetaTypePrivate::isBuiltinSequentialType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) { QSequentialIterable iter = QVariantValueHelperInterface<QSequentialIterable>::invoke(v); QVariantList l; l.reserve(iter.size()); @@ -752,7 +755,8 @@ namespace QtPrivate { { static QVariantHash invoke(const QVariant &v) { - if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) { + const int typeId = v.userType(); + if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) { QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v); QVariantHash l; l.reserve(iter.size()); @@ -768,7 +772,8 @@ namespace QtPrivate { { static QVariantMap invoke(const QVariant &v) { - if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) { + const int typeId = v.userType(); + if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) { QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) @@ -783,10 +788,11 @@ namespace QtPrivate { { static QPair<QVariant, QVariant> invoke(const QVariant &v) { - if (v.userType() == qMetaTypeId<QPair<QVariant, QVariant> >()) + const int typeId = v.userType(); + if (typeId == qMetaTypeId<QPair<QVariant, QVariant> >()) return QVariantValueHelper<QPair<QVariant, QVariant> >::invoke(v); - if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) { + if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) { QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value<QtMetaTypePrivate::QPairVariantInterfaceImpl>(); const QtMetaTypePrivate::VariantData d1 = pi.first(); |