diff options
author | Sérgio Martins <sergio.martins@kdab.com> | 2015-08-12 13:17:58 +0100 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2015-08-13 16:11:48 +0000 |
commit | b5572010798198de7b58ca3b905cb2691a316d1a (patch) | |
tree | b15505115ab0f68fcb6defd338c28a673af8ad65 /src/qml/qml | |
parent | fbdc01f141a4ec4e6fc78ea69d86ff7aa128bf72 (diff) |
qml: Avoid heap allocations due to QString::fromLatin1()
By using QStringLiteral when the argument is a literal.
Change-Id: Ib25042d10f3d9d0aca81af74cde0107aba4f9432
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmldirparser.cpp | 26 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlglobal.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 |
4 files changed, 18 insertions, 18 deletions
diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index a45152e0a0..57b50733ea 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -146,7 +146,7 @@ bool QQmlDirParser::parse(const QString &source) if (invalidLine) { reportError(lineNumber, 0, - QString::fromLatin1("invalid qmldir directive contains too many tokens")); + QStringLiteral("invalid qmldir directive contains too many tokens")); continue; } else if (sectionCount == 0) { continue; // no sections, no party. @@ -154,17 +154,17 @@ bool QQmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("module")) { if (sectionCount != 2) { reportError(lineNumber, 0, - QString::fromLatin1("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1)); + QStringLiteral("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1)); continue; } if (!_typeNamespace.isEmpty()) { reportError(lineNumber, 0, - QString::fromLatin1("only one module identifier directive may be defined in a qmldir file")); + QStringLiteral("only one module identifier directive may be defined in a qmldir file")); continue; } if (!firstLine) { reportError(lineNumber, 0, - QString::fromLatin1("module identifier directive must be the first directive in a qmldir file")); + QStringLiteral("module identifier directive must be the first directive in a qmldir file")); continue; } @@ -173,7 +173,7 @@ bool QQmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("plugin")) { if (sectionCount < 2 || sectionCount > 3) { reportError(lineNumber, 0, - QString::fromLatin1("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); + QStringLiteral("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); continue; } @@ -185,7 +185,7 @@ bool QQmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("internal")) { if (sectionCount != 3) { reportError(lineNumber, 0, - QString::fromLatin1("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); + QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); continue; } Component entry(sections[1], sections[2], -1, -1); @@ -194,7 +194,7 @@ bool QQmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("singleton")) { if (sectionCount < 3 || sectionCount > 4) { reportError(lineNumber, 0, - QString::fromLatin1("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1)); + QStringLiteral("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1)); continue; } else if (sectionCount == 3) { // handle qmldir directory listing case where singleton is defined in the following pattern: @@ -218,7 +218,7 @@ bool QQmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("typeinfo")) { if (sectionCount != 2) { reportError(lineNumber, 0, - QString::fromLatin1("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); + QStringLiteral("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); continue; } #ifdef QT_CREATOR @@ -228,13 +228,13 @@ bool QQmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("designersupported")) { if (sectionCount != 1) - reportError(lineNumber, 0, QString::fromLatin1("designersupported does not expect any argument")); + reportError(lineNumber, 0, QStringLiteral("designersupported does not expect any argument")); else _designerSupported = true; } else if (sections[0] == QLatin1String("depends")) { if (sectionCount != 3) { reportError(lineNumber, 0, - QString::fromLatin1("depends requires 2 arguments, but %1 were provided").arg(sectionCount - 1)); + QStringLiteral("depends requires 2 arguments, but %1 were provided").arg(sectionCount - 1)); continue; } @@ -268,7 +268,7 @@ bool QQmlDirParser::parse(const QString &source) } } else { reportError(lineNumber, 0, - QString::fromLatin1("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); + QStringLiteral("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); } firstLine = false; @@ -364,14 +364,14 @@ bool QQmlDirParser::designerSupported() const QDebug &operator<< (QDebug &debug, const QQmlDirParser::Component &component) { - const QString output = QString::fromLatin1("{%1 %2.%3}"). + const QString output = QStringLiteral("{%1 %2.%3}"). arg(component.typeName).arg(component.majorVersion).arg(component.minorVersion); return debug << qPrintable(output); } QDebug &operator<< (QDebug &debug, const QQmlDirParser::Script &script) { - const QString output = QString::fromLatin1("{%1 %2.%3}"). + const QString output = QStringLiteral("{%1 %2.%3}"). arg(script.nameSpace).arg(script.majorVersion).arg(script.minorVersion); return debug << qPrintable(output); } diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index df5f50644c..70c682dedd 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1638,7 +1638,7 @@ void QQmlData::destroyed(QObject *object) if (location.sourceFile.isEmpty()) location.sourceFile = QStringLiteral("<Unknown File>"); locationString.append(location.sourceFile); - locationString.append(QString::fromLatin1(":%0: ").arg(location.line)); + locationString.append(QStringLiteral(":%0: ").arg(location.line)); QString source = expr->expression(); if (source.size() > 100) { source.truncate(96); diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp index d904242f93..0a2f4079c2 100644 --- a/src/qml/qml/qqmlglobal.cpp +++ b/src/qml/qml/qqmlglobal.cpp @@ -359,7 +359,7 @@ QObject *QQmlGuiProvider::inputMethod() { // We don't have any input method code by default QObject *o = new QObject(); - o->setObjectName(QString::fromLatin1("No inputMethod available")); + o->setObjectName(QStringLiteral("No inputMethod available")); QQmlEngine::setObjectOwnership(o, QQmlEngine::JavaScriptOwnership); return o; } @@ -368,7 +368,7 @@ QObject *QQmlGuiProvider::inputMethod() QObject *QQmlGuiProvider::styleHints() { QObject *o = new QObject(); - o->setObjectName(QString::fromLatin1("No styleHints available")); + o->setObjectName(QStringLiteral("No styleHints available")); QQmlEngine::setObjectOwnership(o, QQmlEngine::JavaScriptOwnership); return o; } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index c0e3b4129b..ce86fd3923 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1355,12 +1355,12 @@ static QString jsStack(QV4::ExecutionEngine *engine) { QString stackFrame; if (frame.column >= 0) - stackFrame = QString::fromLatin1("%1 (%2:%3:%4)").arg(frame.function, + stackFrame = QStringLiteral("%1 (%2:%3:%4)").arg(frame.function, frame.source, QString::number(frame.line), QString::number(frame.column)); else - stackFrame = QString::fromLatin1("%1 (%2:%3)").arg(frame.function, + stackFrame = QStringLiteral("%1 (%2:%3)").arg(frame.function, frame.source, QString::number(frame.line)); |