From cc2938b5b6aa07210b04bd48ad8a2830701a06e5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 24 Jun 2015 02:04:09 +0200 Subject: moc: replace inefficient QLists with QVectors These types are larger than a void*, so holding them in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by marking them movable, and holding them in a QVector instead. Change-Id: I42f494ed87854eadc33d78db4479203ff5e0370f Reviewed-by: Lars Knoll Reviewed-by: Milian Wolff Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/generator.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/tools/moc/generator.cpp') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 587aa5971d..2b09cf873a 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -121,7 +121,7 @@ int Generator::stridx(const QByteArray &s) // Returns the sum of all parameters (including return type) for the given // \a list of methods. This is needed for calculating the size of the methods' // parameter type/name meta-data. -static int aggregateParameterCount(const QList &list) +static int aggregateParameterCount(const QVector &list) { int sum = 0; for (int i = 0; i < list.count(); ++i) @@ -194,7 +194,7 @@ void Generator::generateCode() // filter out undeclared enumerators and sets { - QList enumList; + QVector enumList; for (int i = 0; i < cdef->enumList.count(); ++i) { EnumDef def = cdef->enumList.at(i); if (cdef->enumDeclarations.contains(def.name)) { @@ -571,7 +571,7 @@ void Generator::generateCode() cname, cname, cdef->classname.constData()); } for (int i = 0; i < cdef->interfaceList.size(); ++i) { - const QList &iface = cdef->interfaceList.at(i); + const QVector &iface = cdef->interfaceList.at(i); for (int j = 0; j < iface.size(); ++j) { fprintf(out, " if (!strcmp(_clname, %s))\n return ", iface.at(j).interfaceId.constData()); for (int k = j; k >= 0; --k) @@ -628,7 +628,7 @@ void Generator::generateClassInfos() } } -void Generator::registerFunctionStrings(const QList& list) +void Generator::registerFunctionStrings(const QVector& list) { for (int i = 0; i < list.count(); ++i) { const FunctionDef &f = list.at(i); @@ -648,7 +648,7 @@ void Generator::registerFunctionStrings(const QList& list) } } -void Generator::generateFunctions(const QList& list, const char *functype, int type, int ¶msIndex) +void Generator::generateFunctions(const QVector& list, const char *functype, int type, int ¶msIndex) { if (list.isEmpty()) return; @@ -694,7 +694,7 @@ void Generator::generateFunctions(const QList& list, const char *fu } } -void Generator::generateFunctionRevisions(const QList& list, const char *functype) +void Generator::generateFunctionRevisions(const QVector& list, const char *functype) { if (list.count()) fprintf(out, "\n // %ss: revision\n", functype); @@ -704,7 +704,7 @@ void Generator::generateFunctionRevisions(const QList& list, const } } -void Generator::generateFunctionParameters(const QList& list, const char *functype) +void Generator::generateFunctionParameters(const QVector& list, const char *functype) { if (list.isEmpty()) return; @@ -917,7 +917,7 @@ void Generator::generateMetacall() fprintf(out, " "); bool needElse = false; - QList methodList; + QVector methodList; methodList += cdef->signalList; methodList += cdef->slotList; methodList += cdef->methodList; @@ -1079,7 +1079,7 @@ QMultiMap Generator::automaticPropertyMetaTypesHelper() return automaticPropertyMetaTypes; } -QMap > Generator::methodsWithAutomaticTypesHelper(const QList &methodList) +QMap > Generator::methodsWithAutomaticTypesHelper(const QVector &methodList) { QMap > methodsWithAutomaticTypes; for (int i = 0; i < methodList.size(); ++i) { @@ -1133,7 +1133,7 @@ void Generator::generateStaticMetacall() isUsed_a = true; } - QList methodList; + QVector methodList; methodList += cdef->signalList; methodList += cdef->slotList; methodList += cdef->methodList; -- cgit v1.2.3