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 <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2014-10-08 10:26:27 +02:00
parent 05663e29d0
commit bf1df55846
7 changed files with 19 additions and 19 deletions

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {