summaryrefslogtreecommitdiffstats
path: root/src/script/bridge/qscriptqobject.cpp
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-03-10 09:46:04 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-03-10 16:22:27 (GMT)
commitf3bf93408fa4aa1d6837e08c21b9efa31263348c (patch)
treecc807502d7b2f59d657aca5ae020f9a07f6b549c /src/script/bridge/qscriptqobject.cpp
parenta0164cbfcf2730e99030a2d4e03269acc228d2d4 (diff)
downloadQt-f3bf93408fa4aa1d6837e08c21b9efa31263348c.zip
Qt-f3bf93408fa4aa1d6837e08c21b9efa31263348c.tar.gz
Qt-f3bf93408fa4aa1d6837e08c21b9efa31263348c.tar.bz2
QtScript: Improve performance of type resolution when calling slots
Don't call QVector::append(). We know what the size of the vector will be, so size it initially and work on QVector::data() directly. Reviewed-by: Jedrzej Nowacki
Diffstat (limited to 'src/script/bridge/qscriptqobject.cpp')
-rw-r--r--src/script/bridge/qscriptqobject.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index a96d523..765e074 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -537,40 +537,43 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
continue;
}
+ QList<QByteArray> parameterTypeNames = method.parameterTypes();
+
QVector<QScriptMetaType> types;
+ types.resize(1 + parameterTypeNames.size());
+ QScriptMetaType *typesData = types.data();
// resolve return type
QByteArray returnTypeName = method.typeName();
int rtype = QMetaType::type(returnTypeName);
if ((rtype == 0) && !returnTypeName.isEmpty()) {
int enumIndex = indexOfMetaEnum(meta, returnTypeName);
if (enumIndex != -1)
- types.append(QScriptMetaType::metaEnum(enumIndex, returnTypeName));
+ typesData[0] = QScriptMetaType::metaEnum(enumIndex, returnTypeName);
else
- types.append(QScriptMetaType::unresolved(returnTypeName));
+ typesData[0] = QScriptMetaType::unresolved(returnTypeName);
} else {
if (callType == QMetaMethod::Constructor)
- types.append(QScriptMetaType::metaType(QMetaType::QObjectStar, "QObject*"));
+ typesData[0] = QScriptMetaType::metaType(QMetaType::QObjectStar, "QObject*");
else if (rtype == QMetaType::QVariant)
- types.append(QScriptMetaType::variant());
+ typesData[0] = QScriptMetaType::variant();
else
- types.append(QScriptMetaType::metaType(rtype, returnTypeName));
+ typesData[0] = QScriptMetaType::metaType(rtype, returnTypeName);
}
// resolve argument types
- QList<QByteArray> parameterTypeNames = method.parameterTypes();
for (int i = 0; i < parameterTypeNames.count(); ++i) {
QByteArray argTypeName = parameterTypeNames.at(i);
int atype = QMetaType::type(argTypeName);
if (atype == 0) {
int enumIndex = indexOfMetaEnum(meta, argTypeName);
if (enumIndex != -1)
- types.append(QScriptMetaType::metaEnum(enumIndex, argTypeName));
+ typesData[1 + i] = QScriptMetaType::metaEnum(enumIndex, argTypeName);
else
- types.append(QScriptMetaType::unresolved(argTypeName));
+ typesData[1 + i] = QScriptMetaType::unresolved(argTypeName);
} else if (atype == QMetaType::QVariant) {
- types.append(QScriptMetaType::variant());
+ typesData[1 + i] = QScriptMetaType::variant();
} else {
- types.append(QScriptMetaType::metaType(atype, argTypeName));
+ typesData[1 + i] = QScriptMetaType::metaType(atype, argTypeName);
}
}