From 1977855f3115ab9ad1642b522840ff3424a5f2fe Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Mon, 10 Aug 2015 21:39:04 +0200 Subject: [PATCH] Avoid recreating QVariantLists when extracted from a QVariant Wrapping a QVariantList in a QVariant to pass it to QML would trigger a deep copy each time QML would try to access elements in the list (specifically in QQmlListAccessor::at). This reverts a part of 8c4deff51c8064f5a15cae0342bfa66b6663662b by specifying the associative array conversions explicitly without including the current type in the list of types to convert through an iteration. Task-number: QTBUG-41403 Change-Id: If9fddfe6d36f789ac4aa61a7c32677cd1dd077d8 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qmetatype.h | 15 --------------- src/corelib/kernel/qvariant.h | 6 +++--- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 9e3e1e94fa..b7f01ca5ca 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -2244,21 +2244,6 @@ namespace QtPrivate { }; } -namespace QtMetaTypePrivate { -inline Q_DECL_CONSTEXPR bool isBuiltinSequentialType(int typeId) -{ - return typeId == qMetaTypeId() - || typeId == qMetaTypeId() - || typeId == qMetaTypeId(); -} - -inline Q_DECL_CONSTEXPR bool isBuiltinAssociativeType(int typeId) -{ - return typeId == qMetaTypeId() - || typeId == qMetaTypeId(); -} -} // QtMetaTypePrivate - QT_END_NAMESPACE #endif // QMETATYPE_H diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 27b19982de..4c7e498280 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -750,7 +750,7 @@ namespace QtPrivate { static QVariantList invoke(const QVariant &v) { const int typeId = v.userType(); - if (QtMetaTypePrivate::isBuiltinSequentialType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (typeId == qMetaTypeId() || typeId == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QSequentialIterable iter = QVariantValueHelperInterface::invoke(v); QVariantList l; l.reserve(iter.size()); @@ -767,7 +767,7 @@ namespace QtPrivate { static QVariantHash invoke(const QVariant &v) { const int typeId = v.userType(); - if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (typeId == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QAssociativeIterable iter = QVariantValueHelperInterface::invoke(v); QVariantHash l; l.reserve(iter.size()); @@ -784,7 +784,7 @@ namespace QtPrivate { static QVariantMap invoke(const QVariant &v) { const int typeId = v.userType(); - if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (typeId == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { QAssociativeIterable iter = QVariantValueHelperInterface::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)