From db369d0fa7ff0e15d69dcd30fa6337c2ade3f538 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Wed, 8 Jun 2016 11:08:43 +0200 Subject: [PATCH] QmlDesigner: use QVector as container for PropertyInfo - This seems to be faster, but difficult to measure, was only 1% of the starting time and tested with 100 starts Change-Id: I0273dcd923a4c1e47510e64c0349acda93b0e286 Reviewed-by: Thomas Hartmann --- .../designercore/metainfo/nodemetainfo.cpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index daa0051c6ff..66270c0dfe2 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -76,9 +76,9 @@ using namespace QmlJS; typedef QPair PropertyInfo; -QList getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false, int rec = 0); +QVector getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false, int rec = 0); -static TypeName resolveTypeName(const ASTPropertyReference *ref, const ContextPtr &context, QList &dotProperties) +static TypeName resolveTypeName(const ASTPropertyReference *ref, const ContextPtr &context, QVector &dotProperties) { TypeName type = "unknown"; @@ -281,7 +281,7 @@ public: PropertyName propertyName = name.toUtf8(); const ASTPropertyReference *ref = value_cast(value); if (ref) { - QList dotProperties; + QVector dotProperties; const TypeName type = resolveTypeName(ref, m_context, dotProperties); m_properties.append(qMakePair(propertyName, type)); if (!dotProperties.isEmpty()) { @@ -320,12 +320,12 @@ public: return true; } - QList properties() const { return m_properties; } + QVector properties() const { return m_properties; } PropertyNameList signalList() const { return m_signals; } private: - QList m_properties; + QVector m_properties; PropertyNameList m_signals; const ContextPtr m_context; }; @@ -383,9 +383,9 @@ QStringList prototypes(const ObjectValue *ov, const ContextPtr &context, bool ve return list; } -QList getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0); +QVector getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0); -QList getTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0) +QVector getTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0) { const CppComponentValue * qmlObjectValue = value_cast(objectValue); @@ -395,9 +395,9 @@ QList getTypes(const ObjectValue *objectValue, const ContextPtr &c return getObjectTypes(objectValue, context, local, rec); } -QList getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local, int rec) +QVector getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local, int rec) { - QList propertyList; + QVector propertyList; if (!objectValue) return propertyList; @@ -417,7 +417,7 @@ QList getQmlTypes(const CppComponentValue *objectValue, const Cont //dot property const CppComponentValue * qmlValue = value_cast(objectValue->lookupMember(nameAsString, context)); if (qmlValue) { - const QList dotProperties = getQmlTypes(qmlValue, context, false, rec + 1); + QVector dotProperties = getQmlTypes(qmlValue, context, false, rec + 1); foreach (const PropertyInfo &propertyInfo, dotProperties) { const PropertyName dotName = name + '.' + propertyInfo.first; const TypeName type = propertyInfo.second; @@ -428,7 +428,7 @@ QList getQmlTypes(const CppComponentValue *objectValue, const Cont if (isValueType(objectValue->propertyType(nameAsString))) { const ObjectValue *dotObjectValue = value_cast(objectValue->lookupMember(nameAsString, context)); if (dotObjectValue) { - const QList dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1); + QVector dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1); foreach (const PropertyInfo &propertyInfo, dotProperties) { const PropertyName dotName = name + '.' + propertyInfo.first; const TypeName type = propertyInfo.second; @@ -473,9 +473,9 @@ PropertyNameList getSignals(const ObjectValue *objectValue, const ContextPtr &co return signalList; } -QList getObjectTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local, int rec) +QVector getObjectTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local, int rec) { - QList propertyList; + QVector propertyList; if (!objectValue) return propertyList; @@ -558,8 +558,8 @@ private: const CppComponentValue *getCppComponentValue() const; const ObjectValue *getObjectValue() const; - void setupPropertyInfo(QList propertyInfos); - void setupLocalPropertyInfo(QList propertyInfos); + void setupPropertyInfo(const QVector &propertyInfos); + void setupLocalPropertyInfo(const QVector &propertyInfos); QString lookupName() const; QStringList lookupNameComponent() const; const CppComponentValue *getNearestCppComponentValue() const; @@ -781,14 +781,14 @@ const Document *NodeMetaInfoPrivate::document() const return 0; } -void NodeMetaInfoPrivate::setupLocalPropertyInfo(QList localPropertyInfos) +void NodeMetaInfoPrivate::setupLocalPropertyInfo(const QVector &localPropertyInfos) { foreach (const PropertyInfo &propertyInfo, localPropertyInfos) { m_localProperties.append(propertyInfo.first); } } -void NodeMetaInfoPrivate::setupPropertyInfo(QList propertyInfos) +void NodeMetaInfoPrivate::setupPropertyInfo(const QVector &propertyInfos) { foreach (const PropertyInfo &propertyInfo, propertyInfos) { if (!m_properties.contains(propertyInfo.first)) {