From 1a5c0b26d062a380fef1bb038a9d96cde7556dc6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 8 Oct 2014 11:35:24 +0200 Subject: Don't use QStringLiteral in comparisons For QLatin1String, operator== is overloaded, so comparing to a latin-1 (C) string literal is efficient, since strlen() is comparatively fast. OTOH, QStringLiteral, when not using RVO, litters the code with QString dtor calls, which are not inline. Worse, absent lambdas, it even allocates memory. So, just compare using QLatin1String instead. Change-Id: I7af3bf3a67c55dae33ffaf9922d004fa168a3f9c Reviewed-by: Thiago Macieira --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 2 +- src/platformsupport/services/genericunix/qgenericunixservices.cpp | 2 +- src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 86fd2eaa14..52cb928615 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -201,7 +201,7 @@ void QCoreTextFontDatabase::populateFontDatabase() QString familyName = QCFString::toQString(familyNameRef); // Don't populate internal fonts - if (familyName.startsWith(QLatin1Char('.')) || familyName == QStringLiteral("LastResort")) + if (familyName.startsWith(QLatin1Char('.')) || familyName == QLatin1String("LastResort")) continue; QPlatformFontDatabase::registerFontFamily(familyName); diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 6f13b693d8..e8dd190b52 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -130,7 +130,7 @@ QByteArray QGenericUnixServices::desktopEnvironment() const bool QGenericUnixServices::openUrl(const QUrl &url) { - if (url.scheme() == QStringLiteral("mailto")) + if (url.scheme() == QLatin1String("mailto")) return openDocument(url); if (m_webBrowser.isEmpty() && !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)) { diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index b09dc8563c..e66fdeb7c3 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -234,11 +234,11 @@ void QKdeThemePrivate::refresh() const QVariant toolbarStyleValue = readKdeSetting(QStringLiteral("Toolbar style/ToolButtonStyle"), kdeDirs, kdeSettings); if (toolbarStyleValue.isValid()) { const QString toolBarStyle = toolbarStyleValue.toString(); - if (toolBarStyle == QStringLiteral("TextBesideIcon")) + if (toolBarStyle == QLatin1String("TextBesideIcon")) toolButtonStyle = Qt::ToolButtonTextBesideIcon; - else if (toolBarStyle == QStringLiteral("TextOnly")) + else if (toolBarStyle == QLatin1String("TextOnly")) toolButtonStyle = Qt::ToolButtonTextOnly; - else if (toolBarStyle == QStringLiteral("TextUnderIcon")) + else if (toolBarStyle == QLatin1String("TextUnderIcon")) toolButtonStyle = Qt::ToolButtonTextUnderIcon; } @@ -640,7 +640,7 @@ QStringList QGenericUnixTheme::themeNames() result.push_back(QLatin1String(QGnomeTheme::name)); } const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); - if (!session.isEmpty() && session != QStringLiteral("default") && !result.contains(session)) + if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session)) result.push_back(session); } // desktopSettingsAware if (result.isEmpty()) -- cgit v1.2.3