diff options
author | Sérgio Martins <sergio.martins@kdab.com> | 2015-06-06 16:57:33 +0100 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2015-06-08 11:35:42 +0000 |
commit | 52d91eeea4f49d36c18efd39e12f2634992cb63b (patch) | |
tree | 59cd35f687bcf5b4d02ce6ce24fc8362fa58a171 /src/qml | |
parent | 1790d374718308dc530b14eb004d1504baa2a5c6 (diff) |
Add 28 QList::reserve() calls
Change-Id: Id4820ac458f48b10f2bf457144767efdef9e2c07
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 1 | ||||
-rw-r--r-- | src/qml/debugger/qqmldebugserver.cpp | 13 | ||||
-rw-r--r-- | src/qml/debugger/qqmlenginedebugservice.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmldirparser.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetype.cpp | 4 |
9 files changed, 31 insertions, 7 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 06154d75f0..9731f3bc12 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -695,6 +695,7 @@ bool QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const QmlIR::Ob const int paramCount = s->parameters->count; QList<QByteArray> names; + names.reserve(paramCount); QVarLengthArray<int, 10> paramTypes(paramCount?(paramCount + 1):0); if (paramCount) { diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 9e4c7560c1..ba4bde7a31 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -169,6 +169,7 @@ int QV4::Compiler::JSUnitGenerator::registerJSClass(int count, IR::ExprList *arg // ### re-use existing class definitions. QList<CompiledData::JSClassMember> members; + members.reserve(count); IR::ExprList *it = args; for (int i = 0; i < count; ++i, it = it->next) { diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp index d79028b3fe..a9086ee5d6 100644 --- a/src/qml/debugger/qqmldebugserver.cpp +++ b/src/qml/debugger/qqmldebugserver.cpp @@ -199,7 +199,11 @@ void QQmlDebugServerPrivate::advertisePlugins() QQmlDebugStream out(&message, QIODevice::WriteOnly); QStringList pluginNames; QList<float> pluginVersions; - foreach (QQmlDebugService *service, plugins.values()) { + const QList<QQmlDebugService *> debugServices = plugins.values(); + const int count = debugServices.count(); + pluginNames.reserve(count); + pluginVersions.reserve(count); + foreach (QQmlDebugService *service, debugServices) { pluginNames << service->name(); pluginVersions << service->version(); } @@ -505,7 +509,11 @@ void QQmlDebugServer::receiveMessage(const QByteArray &message) QQmlDebugStream out(&helloAnswer, QIODevice::WriteOnly); QStringList pluginNames; QList<float> pluginVersions; - foreach (QQmlDebugService *service, d->plugins.values()) { + const QList<QQmlDebugService*> debugServices = d->plugins.values(); + const int count = debugServices.count(); + pluginNames.reserve(count); + pluginVersions.reserve(count); + foreach (QQmlDebugService *service, debugServices) { pluginNames << service->name(); pluginVersions << service->version(); } @@ -719,6 +727,7 @@ void QQmlDebugServer::sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages) { QList<QByteArray> prefixedMessages; + prefixedMessages.reserve(messages.count()); foreach (const QByteArray &message, messages) { QByteArray prefixed; QQmlDebugStream out(&prefixed, QIODevice::WriteOnly); diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp index 9bb0ecec89..0a2cb2de05 100644 --- a/src/qml/debugger/qqmlenginedebugservice.cpp +++ b/src/qml/debugger/qqmlenginedebugservice.cpp @@ -192,6 +192,7 @@ QVariant QQmlEngineDebugService::valueContents(QVariant value) const QVariantList contents; QVariantList list = value.toList(); int count = list.size(); + contents.reserve(count); for (int i = 0; i < count; i++) contents << valueContents(list.at(i)); return contents; diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index 7f6310d58e..a45152e0a0 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -304,7 +304,9 @@ QList<QQmlError> QQmlDirParser::errors(const QString &uri) const { QUrl url(uri); QList<QQmlError> errors; - for (int i = 0; i < _errors.size(); ++i) { + const int numErrors = _errors.size(); + errors.reserve(numErrors); + for (int i = 0; i < numErrors; ++i) { const QQmlJS::DiagnosticMessage &msg = _errors.at(i); QQmlError e; QString description = msg.message; diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 2947a03a4a..249ce6942f 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1820,6 +1820,7 @@ QList<QString> QQmlMetaType::qmlTypeNames() QQmlMetaTypeData *data = metaTypeData(); QList<QString> names; + names.reserve(data->nameToType.count()); QQmlMetaTypeData::Names::ConstIterator it = data->nameToType.cbegin(); while (it != data->nameToType.cend()) { names += (*it)->qmlTypeName(); diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 997859d410..e4b2743b9b 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1085,16 +1085,22 @@ QVariant QQmlPropertyPrivate::resolvedUrlSequence(const QVariant &value, QQmlCon urls = value.value<QList<QUrl> >(); } else if (value.userType() == qMetaTypeId<QStringList>()) { QStringList urlStrings = value.value<QStringList>(); - for (int i = 0; i < urlStrings.size(); ++i) + const int urlStringsSize = urlStrings.size(); + urls.reserve(urlStringsSize); + for (int i = 0; i < urlStringsSize; ++i) urls.append(QUrl(urlStrings.at(i))); } else if (value.userType() == qMetaTypeId<QList<QString> >()) { QList<QString> urlStrings = value.value<QList<QString> >(); - for (int i = 0; i < urlStrings.size(); ++i) + const int urlStringsSize = urlStrings.size(); + urls.reserve(urlStringsSize); + for (int i = 0; i < urlStringsSize; ++i) urls.append(QUrl(urlStrings.at(i))); } // note: QList<QByteArray> is not currently supported. QList<QUrl> resolvedUrls; - for (int i = 0; i < urls.size(); ++i) { + const int urlsSize = urls.size(); + resolvedUrls.reserve(urlsSize); + for (int i = 0; i < urlsSize; ++i) { QUrl u = urls.at(i); if (context && u.isRelative() && !u.isEmpty()) u = context->resolvedUrl(u); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index c04d2fac82..c78bbaf30b 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2114,6 +2114,7 @@ void QQmlTypeData::dataReceived(const Data &data) QmlIR::IRBuilder compiler(QV8Engine::get(qmlEngine)->illegalNames()); if (!compiler.generateFromQml(code, finalUrlString(), m_document.data())) { QList<QQmlError> errors; + errors.reserve(compiler.errors.count()); foreach (const QQmlJS::DiagnosticMessage &msg, compiler.errors) { QQmlError e; e.setUrl(finalUrl()); diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index 341ddf802d..cc4a9bebc5 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -478,7 +478,9 @@ void QQmlEasingValueType::setBezierCurve(const QVariantList &customCurveVariant) if ((variantList.count() % 6) == 0) { bool allRealsOk = true; QList<qreal> reals; - for (int i = 0; i < variantList.count(); i++) { + const int variantListCount = variantList.count(); + reals.reserve(variantListCount); + for (int i = 0; i < variantListCount; i++) { bool ok; const qreal real = variantList.at(i).toReal(&ok); reals.append(real); |