QtCore: replace QStringLiteral with QLatin1String when appending

It makes little sense to use QStringLiteral for strings which are
immediately appended to, or which are appended to other strings,
because no dynamic memory allocation is saved by doing so. But if
the only advantage of QStringLiteral does not apply, all its
disadvantages dominate, to wit: injection of calls to qstring dtor,
non-sharability of data between C strings and QStringLiterals and
among QStringLiterals, and doubled storage requirements.

Fix by replacing QStringLiteral with QLatin1String.

Saves 1156B in text size on stripped optimized Linux AMD64 GCC 4.9
builds.

Change-Id: If805e431f570ec1d2ac62c548f516f1b17390c3a
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2015-02-28 15:18:11 +01:00
parent 8b5651eb41
commit 8dc024adc6
5 changed files with 5 additions and 5 deletions

View File

@ -581,7 +581,7 @@ QFile::rename(const QString &newName)
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
// rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive // rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive
// FS, such as FAT32. Move the file away and rename in 2 steps to work around. // FS, such as FAT32. Move the file away and rename in 2 steps to work around.
QTemporaryFile tempFile(d->fileName + QStringLiteral(".XXXXXX")); QTemporaryFile tempFile(d->fileName + QLatin1String(".XXXXXX"));
tempFile.setAutoRemove(false); tempFile.setAutoRemove(false);
if (!tempFile.open(QIODevice::ReadWrite)) { if (!tempFile.open(QIODevice::ReadWrite)) {
d->setError(QFile::RenameError, tempFile.errorString()); d->setError(QFile::RenameError, tempFile.errorString());

View File

@ -227,7 +227,7 @@ bool QLockFile::tryLock(int timeout)
if (!d->isLocked && d->isApparentlyStale()) { if (!d->isLocked && d->isApparentlyStale()) {
// Stale lock from another thread/process // Stale lock from another thread/process
// Ensure two processes don't remove it at the same time // Ensure two processes don't remove it at the same time
QLockFile rmlock(d->fileName + QStringLiteral(".rmlock")); QLockFile rmlock(d->fileName + QLatin1String(".rmlock"));
if (rmlock.tryLock()) { if (rmlock.tryLock()) {
if (d->isApparentlyStale() && d->removeStaleLock()) if (d->isApparentlyStale() && d->removeStaleLock())
continue; continue;

View File

@ -4271,7 +4271,7 @@ QUrl QUrl::fromUserInput(const QString &userInput)
return QUrl::fromLocalFile(trimmedString); return QUrl::fromLocalFile(trimmedString);
QUrl url = QUrl(trimmedString, QUrl::TolerantMode); QUrl url = QUrl(trimmedString, QUrl::TolerantMode);
QUrl urlPrepended = QUrl(QStringLiteral("http://") + trimmedString, QUrl::TolerantMode); QUrl urlPrepended = QUrl(QLatin1String("http://") + trimmedString, QUrl::TolerantMode);
// Check the most common case of a valid url with a scheme // Check the most common case of a valid url with a scheme
// We check if the port would be valid by adding the scheme to handle the case host:port // We check if the port would be valid by adding the scheme to handle the case host:port

View File

@ -1029,7 +1029,7 @@ QString QCommandLineParser::helpText() const
static QString wrapText(const QString &names, int longestOptionNameString, const QString &description) static QString wrapText(const QString &names, int longestOptionNameString, const QString &description)
{ {
const QLatin1Char nl('\n'); const QLatin1Char nl('\n');
QString text = QStringLiteral(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); QString text = QLatin1String(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' ');
const int indent = text.length(); const int indent = text.length();
int lineStart = 0; int lineStart = 0;
int lastBreakable = -1; int lastBreakable = -1;

View File

@ -378,7 +378,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
m_standardName = readRegistryString(baseKey, L"Std"); m_standardName = readRegistryString(baseKey, L"Std");
m_daylightName = readRegistryString(baseKey, L"Dlt"); m_daylightName = readRegistryString(baseKey, L"Dlt");
// On Vista and later the optional dynamic key holds historic data // On Vista and later the optional dynamic key holds historic data
const QString dynamicKeyPath = baseKeyPath + QStringLiteral("\\Dynamic DST"); const QString dynamicKeyPath = baseKeyPath + QLatin1String("\\Dynamic DST");
HKEY dynamicKey = NULL; HKEY dynamicKey = NULL;
if (openRegistryKey(dynamicKeyPath, &dynamicKey)) { if (openRegistryKey(dynamicKeyPath, &dynamicKey)) {
// Find out the start and end years stored, then iterate over them // Find out the start and end years stored, then iterate over them