From f0b7abf2ef723432b387dfc5e0706675a9447133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Wed, 22 Oct 2014 15:17:41 +0200 Subject: 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 --- src/corelib/kernel/qvariant.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/corelib/kernel') 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()) { + const int typeId = v.userType(); + if (typeId == qMetaTypeId()) { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast(v.constData()))); } - if (v.userType() == qMetaTypeId()) { + if (typeId == qMetaTypeId()) { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast(v.constData()))); } #ifndef QT_BOOTSTRAPPED - if (v.userType() == qMetaTypeId()) { + if (typeId == qMetaTypeId()) { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast(v.constData()))); } #endif @@ -722,10 +723,11 @@ namespace QtPrivate { { static QAssociativeIterable invoke(const QVariant &v) { - if (v.userType() == qMetaTypeId()) { + const int typeId = v.userType(); + if (typeId == qMetaTypeId()) { return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast(v.constData()))); } - if (v.userType() == qMetaTypeId()) { + if (typeId == qMetaTypeId()) { return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast(v.constData()))); } return QAssociativeIterable(v.value()); @@ -736,7 +738,8 @@ namespace QtPrivate { { static QVariantList invoke(const QVariant &v) { - if (QtMetaTypePrivate::isBuiltinSequentialType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { + const int typeId = v.userType(); + if (QtMetaTypePrivate::isBuiltinSequentialType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QSequentialIterable iter = QVariantValueHelperInterface::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())) { + const int typeId = v.userType(); + if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QAssociativeIterable iter = QVariantValueHelperInterface::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())) { + const int typeId = v.userType(); + if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QAssociativeIterable iter = QVariantValueHelperInterface::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 invoke(const QVariant &v) { - if (v.userType() == qMetaTypeId >()) + const int typeId = v.userType(); + if (typeId == qMetaTypeId >()) return QVariantValueHelper >::invoke(v); - if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { + if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value(); const QtMetaTypePrivate::VariantData d1 = pi.first(); -- cgit v1.2.3