diff options
author | Marc Mutz <[email protected]> | 2014-10-08 10:26:27 +0200 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2014-10-09 09:41:51 +0200 |
commit | bf1df558461f21827eaad9d5d9541def784980a2 (patch) | |
tree | 1c58599a96968000808362b47f069302fa0582ee | |
parent | 05663e29d047851adb9a1ef440fb78b38ff3cc9b (diff) |
Don't use QByteArrayLiteral in comparisons
For const char*s, operator== is overloaded, so comparing to a (C) string
literal is efficient, since qstrcmp doesn't require the length of the
strings to compare.
OTOH, QByteArrayLiteral, when not using RVO, litters the code with
QByteArray dtor calls, which are not inline. Worse, absent lambdas,
it even allocates memory.
So, just compare with a (C) string literal instead.
Change-Id: Id3bfdc89558ba51911f6317a7a73c287f96e6f24
Reviewed-by: Thiago Macieira <[email protected]>
-rw-r--r-- | src/network/ssl/qsslcertificate_qt.cpp | 8 | ||||
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 14 | ||||
-rw-r--r-- | src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsintegration.cpp | 6 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsscaling.cpp | 2 | ||||
-rw-r--r-- | src/printsupport/kernel/qprint_p.h | 4 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 2 |
7 files changed, 19 insertions, 19 deletions
diff --git a/src/network/ssl/qsslcertificate_qt.cpp b/src/network/ssl/qsslcertificate_qt.cpp index 8019416aba8..16df4a8f730 100644 --- a/src/network/ssl/qsslcertificate_qt.cpp +++ b/src/network/ssl/qsslcertificate_qt.cpp @@ -444,7 +444,7 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific QAsn1Element val; bool supported = true; QVariant value; - if (oid == QByteArrayLiteral("1.3.6.1.5.5.7.1.1")) { + if (oid == "1.3.6.1.5.5.7.1.1") { // authorityInfoAccess if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType) return false; @@ -463,12 +463,12 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific } } value = result; - } else if (oid == QByteArrayLiteral("2.5.29.14")) { + } else if (oid == "2.5.29.14") { // subjectKeyIdentifier if (!val.read(valElem.value()) || val.type() != QAsn1Element::OctetStringType) return false; value = colonSeparatedHex(val.value()).toUpper(); - } else if (oid == QByteArrayLiteral("2.5.29.19")) { + } else if (oid == "2.5.29.19") { // basicConstraints if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType) return false; @@ -488,7 +488,7 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific return false; } value = result; - } else if (oid == QByteArrayLiteral("2.5.29.35")) { + } else if (oid == "2.5.29.35") { // authorityKeyIdentifier if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType) return false; diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 4c2051ebd04..b09dc8563c6 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -624,16 +624,16 @@ QStringList QGenericUnixTheme::themeNames() QStringList result; if (QGuiApplication::desktopSettingsAware()) { const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment(); - if (desktopEnvironment == QByteArrayLiteral("KDE")) { + if (desktopEnvironment == "KDE") { #ifndef QT_NO_SETTINGS result.push_back(QLatin1String(QKdeTheme::name)); #endif - } else if (desktopEnvironment == QByteArrayLiteral("GNOME") || - desktopEnvironment == QByteArrayLiteral("X-CINNAMON") || - desktopEnvironment == QByteArrayLiteral("UNITY") || - desktopEnvironment == QByteArrayLiteral("MATE") || - desktopEnvironment == QByteArrayLiteral("XFCE") || - desktopEnvironment == QByteArrayLiteral("LXDE")) { // Gtk-based desktops + } else if (desktopEnvironment == "GNOME" || + desktopEnvironment == "X-CINNAMON" || + desktopEnvironment == "UNITY" || + desktopEnvironment == "MATE" || + desktopEnvironment == "XFCE" || + desktopEnvironment == "LXDE") { // Gtk-based desktops // prefer the GTK2 theme implementation with native dialogs etc. result.push_back(QStringLiteral("gtk2")); // fallback to the generic Gnome theme if loading the GTK2 theme fails diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp index bd5c3d51d26..4e83f75a1ab 100644 --- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp @@ -127,7 +127,7 @@ void QQnxButtonEventNotifier::updateButtonStates() for (int buttonId = bid_minus; buttonId < ButtonCount; ++buttonId) { // Extract the new button state QByteArray key = m_buttonKeys.at(buttonId); - ButtonState newState = (fields.value(key) == QByteArrayLiteral("b_up") ? ButtonUp : ButtonDown); + ButtonState newState = (fields.value(key) == "b_up" ? ButtonUp : ButtonDown); // If state has changed, update our state and inject a keypress event if (m_state[buttonId] != newState) { diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 84b71925e1b..54fb138d851 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -336,9 +336,9 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() #if defined(QT_OPENGL_DYNAMIC) const QByteArray requested = qgetenv("QT_OPENGL"); // angle, desktop, software - const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == QByteArrayLiteral("angle"); - const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == QByteArrayLiteral("desktop"); - const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == QByteArrayLiteral("software"); + const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == "angle"; + const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == "desktop"; + const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == "software"; // If ANGLE is requested, use it, don't try anything else. if (angleRequested) { diff --git a/src/plugins/platforms/windows/qwindowsscaling.cpp b/src/plugins/platforms/windows/qwindowsscaling.cpp index ae1a7d4dedb..8f0dab82f68 100644 --- a/src/plugins/platforms/windows/qwindowsscaling.cpp +++ b/src/plugins/platforms/windows/qwindowsscaling.cpp @@ -58,7 +58,7 @@ int QWindowsScaling::determineUiScaleFactor() return 1; const QByteArray envDevicePixelRatioEnv = qgetenv(devicePixelRatioEnvVar); // Auto: Suggest a scale factor by checking monitor resolution. - if (envDevicePixelRatioEnv == QByteArrayLiteral("auto")) { + if (envDevicePixelRatioEnv == "auto") { const int maxResolution = QWindowsScreen::maxMonitorHorizResolution(); return maxResolution > 180 ? maxResolution / 96 : 1; } diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h index c674290d168..504a0d6e20e 100644 --- a/src/printsupport/kernel/qprint_p.h +++ b/src/printsupport/kernel/qprint_p.h @@ -277,9 +277,9 @@ public: static QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice) { - if (choice == QByteArrayLiteral("DuplexTumble")) + if (choice == "DuplexTumble") return QPrint::DuplexShortSide; - else if (choice == QByteArrayLiteral("DuplexNoTumble")) + else if (choice == "DuplexNoTumble") return QPrint::DuplexLongSide; else // None or SimplexTumble or SimplexNoTumble return QPrint::DuplexNone; diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 1a12b334e6d..1f7b18e8247 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3254,7 +3254,7 @@ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *resu { #if !defined(QT_NO_STYLE_WINDOWSVISTA) Q_D(QWizard); - if (d->isVistaThemeEnabled() && eventType == QByteArrayLiteral("windows_generic_MSG")) { + if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") { MSG *windowsMessage = static_cast<MSG *>(message); const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result); if (QVistaHelper::vistaState() != d->vistaState) { |