From 68a85a03f96f5912151ff7412c508e52a27c9418 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 28 Feb 2015 15:19:44 +0100 Subject: [PATCH] QtWidgets: 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 288B in text size on stripped optimized Linux AMD64 GCC 4.9 builds. Change-Id: Ie632f25883163f57991264b29e8753fe4c4f738e Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/dialogs/qfiledialog.cpp | 2 +- src/widgets/kernel/qwidgetwindow.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 4d74292e8f..50667e2a91 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1527,7 +1527,7 @@ static QString nameFilterForMime(const QString &mimeType) return QFileDialog::tr("All files (*)"); } else { const QString patterns = mime.globPatterns().join(QLatin1Char(' ')); - return mime.comment() + QStringLiteral(" (") + patterns + QLatin1Char(')'); + return mime.comment() + QLatin1String(" (") + patterns + QLatin1Char(')'); } } return QString(); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 90473c6642..6a3785ea03 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -1001,8 +1001,8 @@ void QWidgetWindow::updateObjectName() { QString name = m_widget->objectName(); if (name.isEmpty()) - name = QString::fromUtf8(m_widget->metaObject()->className()) + QStringLiteral("Class"); - name += QStringLiteral("Window"); + name = QString::fromUtf8(m_widget->metaObject()->className()) + QLatin1String("Class"); + name += QLatin1String("Window"); setObjectName(name); }