From 9c357d64db3aedba6802e9a508abbbdc67f3ef8d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 3 Jun 2019 23:08:05 +0200 Subject: [PATCH] QtCore: use new QLatin1String::arg() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saves ~600B in text size on optimized GCC 9.1 Linux AMD64 builds. Change-Id: I12f4e7c8d28af9549b481859bc96a155aeb6f15c Reviewed-by: Edward Welbourne Reviewed-by: MÃ¥rten Nordheim --- src/corelib/io/qfile.cpp | 2 +- src/corelib/io/qstandardpaths_android.cpp | 2 +- src/corelib/io/qurl.cpp | 18 +++++++++--------- src/corelib/kernel/qjni.cpp | 8 ++++---- .../kernel/qsystemsemaphore_systemv.cpp | 6 +++--- src/corelib/plugin/qlibrary_unix.cpp | 12 ++++++------ 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 6959c7a40b..9f9a9e3040 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -810,7 +810,7 @@ QFile::copy(const QString &newName) error = true; d->setError(QFile::CopyError, tr("Cannot open %1 for input").arg(d->fileName)); } else { - QString fileTemplate = QLatin1String("%1/qt_temp.XXXXXX"); + const auto fileTemplate = QLatin1String("%1/qt_temp.XXXXXX"); #ifdef QT_NO_TEMPORARYFILE QFile out(fileTemplate.arg(QFileInfo(newName).path())); if (!out.open(QIODevice::ReadWrite)) diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp index 83108e4387..1f4e0de1e7 100644 --- a/src/corelib/io/qstandardpaths_android.cpp +++ b/src/corelib/io/qstandardpaths_android.cpp @@ -136,7 +136,7 @@ static QString getExternalStoragePublicDirectory(const char *directoryField) */ static QString getExternalFilesDir(const char *directoryField = 0) { - QString &path = (*androidDirCache)[QString(QLatin1String("APPNAME_%1")).arg(QLatin1String(directoryField))]; + QString &path = (*androidDirCache)[QLatin1String("APPNAME_%1").arg(QLatin1String(directoryField))]; if (!path.isEmpty()) return path; diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index f82ad48b2c..d9ebc6c750 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3991,21 +3991,21 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err return QString(); case QUrlPrivate::InvalidSchemeError: { - QString msg = QStringLiteral("Invalid scheme (character '%1' not permitted)"); + auto msg = QLatin1String("Invalid scheme (character '%1' not permitted)"); return msg.arg(c); } case QUrlPrivate::InvalidUserNameError: - return QString(QStringLiteral("Invalid user name (character '%1' not permitted)")) + return QLatin1String("Invalid user name (character '%1' not permitted)") .arg(c); case QUrlPrivate::InvalidPasswordError: - return QString(QStringLiteral("Invalid password (character '%1' not permitted)")) + return QLatin1String("Invalid password (character '%1' not permitted)") .arg(c); case QUrlPrivate::InvalidRegNameError: if (errorPosition != -1) - return QString(QStringLiteral("Invalid hostname (character '%1' not permitted)")) + return QLatin1String("Invalid hostname (character '%1' not permitted)") .arg(c); else return QStringLiteral("Invalid hostname (contains invalid characters)"); @@ -4014,9 +4014,9 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err case QUrlPrivate::InvalidIPv6AddressError: return QStringLiteral("Invalid IPv6 address"); case QUrlPrivate::InvalidCharacterInIPv6Error: - return QStringLiteral("Invalid IPv6 address (character '%1' not permitted)").arg(c); + return QLatin1String("Invalid IPv6 address (character '%1' not permitted)").arg(c); case QUrlPrivate::InvalidIPvFutureError: - return QStringLiteral("Invalid IPvFuture address (character '%1' not permitted)").arg(c); + return QLatin1String("Invalid IPvFuture address (character '%1' not permitted)").arg(c); case QUrlPrivate::HostMissingEndBracket: return QStringLiteral("Expected ']' to match '[' in hostname"); @@ -4026,15 +4026,15 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err return QStringLiteral("Port field was empty"); case QUrlPrivate::InvalidPathError: - return QString(QStringLiteral("Invalid path (character '%1' not permitted)")) + return QLatin1String("Invalid path (character '%1' not permitted)") .arg(c); case QUrlPrivate::InvalidQueryError: - return QString(QStringLiteral("Invalid query (character '%1' not permitted)")) + return QLatin1String("Invalid query (character '%1' not permitted)") .arg(c); case QUrlPrivate::InvalidFragmentError: - return QString(QStringLiteral("Invalid fragment (character '%1' not permitted)")) + return QLatin1String("Invalid fragment (character '%1' not permitted)") .arg(c); case QUrlPrivate::AuthorityPresentAndPathIsRelative: diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 75a2436d9d..5f652d70e3 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -47,9 +47,9 @@ QT_BEGIN_NAMESPACE -static inline QString keyBase() +static inline QLatin1String keyBase() { - return QStringLiteral("%1%2:%3"); + return QLatin1String("%1%2:%3"); } static QString qt_convertJString(jstring string) @@ -154,7 +154,7 @@ static jmethodID getCachedMethodID(JNIEnv *env, if (className.isEmpty()) return getMethodID(env, clazz, name, sig, isStatic); - const QString key = keyBase().arg(QLatin1String(className)).arg(QLatin1String(name)).arg(QLatin1String(sig)); + const QString key = keyBase().arg(QLatin1String(className), QLatin1String(name), QLatin1String(sig)); QHash::const_iterator it; { @@ -206,7 +206,7 @@ static jfieldID getCachedFieldID(JNIEnv *env, if (className.isNull()) return getFieldID(env, clazz, name, sig, isStatic); - const QString key = keyBase().arg(QLatin1String(className)).arg(QLatin1String(name)).arg(QLatin1String(sig)); + const QString key = keyBase().arg(QLatin1String(className), QLatin1String(name), QLatin1String(sig)); QHash::const_iterator it; { diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp index 9e438ae2a6..2c38d74d2d 100644 --- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp +++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp @@ -76,7 +76,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode) #if QT_CONFIG(translation) QCoreApplication::tr("%1: key is empty", "QSystemSemaphore") #else - QString::fromLatin1("%1: key is empty") + QLatin1String("%1: key is empty") #endif .arg(QLatin1String("QSystemSemaphore::handle:")); error = QSystemSemaphore::KeyError; @@ -94,7 +94,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode) #if QT_CONFIG(translation) QCoreApplication::tr("%1: unable to make key", "QSystemSemaphore") #else - QString::fromLatin1("%1: unable to make key") + QLatin1String("%1: unable to make key") #endif .arg(QLatin1String("QSystemSemaphore::handle:")); error = QSystemSemaphore::KeyError; @@ -111,7 +111,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode) #if QT_CONFIG(translation) QCoreApplication::tr("%1: ftok failed", "QSystemSemaphore") #else - QString::fromLatin1("%1: ftok failed") + QLatin1String("%1: ftok failed") #endif .arg(QLatin1String("QSystemSemaphore::handle:")); error = QSystemSemaphore::KeyError; diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index e03814984c..84fcc53d52 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -77,14 +77,14 @@ QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion) // .so is preferred. # if defined(__ia64) if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); + suffixes << QLatin1String(".so.%1").arg(fullVersion); } else { suffixes << QLatin1String(".so"); } # endif if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".sl.%1").arg(fullVersion); - suffixes << QString::fromLatin1(".%1").arg(fullVersion); + suffixes << QLatin1String(".sl.%1").arg(fullVersion); + suffixes << QLatin1String(".%1").arg(fullVersion); } else { suffixes << QLatin1String(".sl"); } @@ -93,15 +93,15 @@ QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion) #else if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); + suffixes << QLatin1String(".so.%1").arg(fullVersion); } else { suffixes << QLatin1String(".so"); } #endif # ifdef Q_OS_MAC if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".%1.bundle").arg(fullVersion); - suffixes << QString::fromLatin1(".%1.dylib").arg(fullVersion); + suffixes << QLatin1String(".%1.bundle").arg(fullVersion); + suffixes << QLatin1String(".%1.dylib").arg(fullVersion); } else { suffixes << QLatin1String(".bundle") << QLatin1String(".dylib"); }