summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-06-24 02:04:09 +0200
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2016-02-10 16:00:46 +0000
commitcc2938b5b6aa07210b04bd48ad8a2830701a06e5 (patch)
tree5e9719c9eace2947e542f2ee34c0f23589e3e7e6 /src/tools/moc/moc.h
parent3e63a58a96bc9d7fc6004f3a8eacc062bae953f9 (diff)
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 <lars.knoll@theqtcompany.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools/moc/moc.h')
-rw-r--r--src/tools/moc/moc.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index cca14d1fce..843bdeb794 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -59,6 +59,7 @@ struct Type
Token firstToken;
ReferenceType referenceType;
};
+Q_DECLARE_TYPEINFO(Type, Q_MOVABLE_TYPE);
struct EnumDef
{
@@ -67,6 +68,7 @@ struct EnumDef
bool isEnumClass; // c++11 enum class
EnumDef() : isEnumClass(false) {}
};
+Q_DECLARE_TYPEINFO(EnumDef, Q_MOVABLE_TYPE);
struct ArgumentDef
{
@@ -76,6 +78,7 @@ struct ArgumentDef
QByteArray typeNameForCast; // type name to be used in cast from void * in metacall
bool isDefault;
};
+Q_DECLARE_TYPEINFO(ArgumentDef, Q_MOVABLE_TYPE);
struct FunctionDef
{
@@ -89,7 +92,7 @@ struct FunctionDef
QByteArray name;
bool returnTypeIsVolatile;
- QList<ArgumentDef> arguments;
+ QVector<ArgumentDef> arguments;
enum Access { Private, Protected, Public };
Access access;
@@ -112,6 +115,7 @@ struct FunctionDef
int revision;
};
+Q_DECLARE_TYPEINFO(FunctionDef, Q_MOVABLE_TYPE);
struct PropertyDef
{
@@ -130,6 +134,7 @@ struct PropertyDef
}
int revision;
};
+Q_DECLARE_TYPEINFO(PropertyDef, Q_MOVABLE_TYPE);
struct ClassInfoDef
@@ -137,6 +142,7 @@ struct ClassInfoDef
QByteArray name;
QByteArray value;
};
+Q_DECLARE_TYPEINFO(ClassInfoDef, Q_MOVABLE_TYPE);
struct ClassDef {
ClassDef():
@@ -144,16 +150,17 @@ struct ClassDef {
, revisionedMethods(0), revisionedProperties(0), begin(0), end(0){}
QByteArray classname;
QByteArray qualified;
- QList<QPair<QByteArray, FunctionDef::Access> > superclassList;
+ QVector<QPair<QByteArray, FunctionDef::Access> > superclassList;
struct Interface
{
+ Interface() {} // for QVector, don't use
inline explicit Interface(const QByteArray &_className)
: className(_className) {}
QByteArray className;
QByteArray interfaceId;
};
- QList<QList<Interface> >interfaceList;
+ QVector<QVector<Interface> >interfaceList;
bool hasQObject;
bool hasQGadget;
@@ -164,13 +171,13 @@ struct ClassDef {
QJsonDocument metaData;
} pluginData;
- QList<FunctionDef> constructorList;
- QList<FunctionDef> signalList, slotList, methodList, publicList;
+ QVector<FunctionDef> constructorList;
+ QVector<FunctionDef> signalList, slotList, methodList, publicList;
int notifyableProperties;
- QList<PropertyDef> propertyList;
- QList<ClassInfoDef> classInfoList;
+ QVector<PropertyDef> propertyList;
+ QVector<ClassInfoDef> classInfoList;
QMap<QByteArray, bool> enumDeclarations;
- QList<EnumDef> enumList;
+ QVector<EnumDef> enumList;
QMap<QByteArray, QByteArray> flagAliases;
int revisionedMethods;
int revisionedProperties;
@@ -178,12 +185,15 @@ struct ClassDef {
int begin;
int end;
};
+Q_DECLARE_TYPEINFO(ClassDef, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(ClassDef::Interface, Q_MOVABLE_TYPE);
struct NamespaceDef {
QByteArray name;
int begin;
int end;
};
+Q_DECLARE_TYPEINFO(NamespaceDef, Q_MOVABLE_TYPE);
class Moc : public Parser
{
@@ -198,7 +208,7 @@ public:
bool mustIncludeQPluginH;
QByteArray includePath;
QList<QByteArray> includeFiles;
- QList<ClassDef> classList;
+ QVector<ClassDef> classList;
QMap<QByteArray, QByteArray> interface2IdMap;
QList<QByteArray> metaTypes;
// map from class name to fully qualified name