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: I761b2b26ab5b416bc695f524a9ee607dacf0a7b2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
58f8dd4f92
commit
0f27d11285
@ -121,14 +121,14 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
|
||||
bool haveDirectConnection = false;
|
||||
foreach (const QUrl& url, rawProxies) {
|
||||
QNetworkProxy::ProxyType type;
|
||||
if (url.scheme() == QStringLiteral("http")) {
|
||||
if (url.scheme() == QLatin1String("http")) {
|
||||
type = QNetworkProxy::HttpProxy;
|
||||
} else if (url.scheme() == QStringLiteral("socks")
|
||||
|| url.scheme() == QStringLiteral("socks5")) {
|
||||
} else if (url.scheme() == QLatin1String("socks")
|
||||
|| url.scheme() == QLatin1String("socks5")) {
|
||||
type = QNetworkProxy::Socks5Proxy;
|
||||
} else if (url.scheme() == QStringLiteral("ftp")) {
|
||||
} else if (url.scheme() == QLatin1String("ftp")) {
|
||||
type = QNetworkProxy::FtpCachingProxy;
|
||||
} else if (url.scheme() == QStringLiteral("direct")) {
|
||||
} else if (url.scheme() == QLatin1String("direct")) {
|
||||
type = QNetworkProxy::NoProxy;
|
||||
haveDirectConnection = true;
|
||||
} else {
|
||||
|
@ -1961,71 +1961,71 @@ namespace
|
||||
// https://bugzilla.gnome.org/show_bug.cgi?id=744553 "ATK docs provide no guidance for allowed values of some text attributes"
|
||||
// specifically for "weight", "invalid", "language" and value range for colors
|
||||
|
||||
if (ia2Name == QStringLiteral("background-color")) {
|
||||
if (ia2Name == QLatin1String("background-color")) {
|
||||
name = QStringLiteral("bg-color");
|
||||
value = atspiColor(value);
|
||||
} else if (ia2Name == QStringLiteral("font-family")) {
|
||||
} else if (ia2Name == QLatin1String("font-family")) {
|
||||
name = QStringLiteral("family-name");
|
||||
} else if (ia2Name == QStringLiteral("color")) {
|
||||
} else if (ia2Name == QLatin1String("color")) {
|
||||
name = QStringLiteral("fg-color");
|
||||
value = atspiColor(value);
|
||||
} else if (ia2Name == QStringLiteral("text-align")) {
|
||||
} else if (ia2Name == QLatin1String("text-align")) {
|
||||
name = QStringLiteral("justification");
|
||||
if (value == QStringLiteral("justify")) {
|
||||
if (value == QLatin1String("justify")) {
|
||||
value = QStringLiteral("fill");
|
||||
} else {
|
||||
if (value != QStringLiteral("left") &&
|
||||
value != QStringLiteral("right") &&
|
||||
value != QStringLiteral("center")
|
||||
if (value != QLatin1String("left") &&
|
||||
value != QLatin1String("right") &&
|
||||
value != QLatin1String("center")
|
||||
) {
|
||||
value = QString();
|
||||
qAtspiDebug() << "Unknown text-align attribute value \"" << value << "\" cannot be translated to AT-SPI.";
|
||||
}
|
||||
}
|
||||
} else if (ia2Name == QStringLiteral("font-size")) {
|
||||
} else if (ia2Name == QLatin1String("font-size")) {
|
||||
name = QStringLiteral("size");
|
||||
value = atspiSize(value);
|
||||
} else if (ia2Name == QStringLiteral("font-style")) {
|
||||
} else if (ia2Name == QLatin1String("font-style")) {
|
||||
name = QStringLiteral("style");
|
||||
if (value != QStringLiteral("normal") &&
|
||||
value != QStringLiteral("italic") &&
|
||||
value != QStringLiteral("oblique")
|
||||
if (value != QLatin1String("normal") &&
|
||||
value != QLatin1String("italic") &&
|
||||
value != QLatin1String("oblique")
|
||||
) {
|
||||
value = QString();
|
||||
qAtspiDebug() << "Unknown font-style attribute value \"" << value << "\" cannot be translated to AT-SPI.";
|
||||
}
|
||||
} else if (ia2Name == QStringLiteral("text-underline-type")) {
|
||||
} else if (ia2Name == QLatin1String("text-underline-type")) {
|
||||
name = QStringLiteral("underline");
|
||||
if (value != QStringLiteral("none") &&
|
||||
value != QStringLiteral("single") &&
|
||||
value != QStringLiteral("double")
|
||||
if (value != QLatin1String("none") &&
|
||||
value != QLatin1String("single") &&
|
||||
value != QLatin1String("double")
|
||||
) {
|
||||
value = QString();
|
||||
qAtspiDebug() << "Unknown text-underline-type attribute value \"" << value << "\" cannot be translated to AT-SPI.";
|
||||
}
|
||||
} else if (ia2Name == QStringLiteral("font-weight")) {
|
||||
} else if (ia2Name == QLatin1String("font-weight")) {
|
||||
name = QStringLiteral("weight");
|
||||
if (value == QStringLiteral("normal"))
|
||||
if (value == QLatin1String("normal"))
|
||||
// Orca seems to accept all IAccessible2 values except for "normal"
|
||||
// (on which it produces traceback and fails to read any following text attributes),
|
||||
// but that is the default value, so omit it anyway
|
||||
value = QString();
|
||||
} else if (ia2Name == QStringLiteral("text-position")) {
|
||||
} else if (ia2Name == QLatin1String("text-position")) {
|
||||
name = QStringLiteral("vertical-align");
|
||||
if (value != QStringLiteral("baseline") &&
|
||||
value != QStringLiteral("super") &&
|
||||
value != QStringLiteral("sub")
|
||||
if (value != QLatin1String("baseline") &&
|
||||
value != QLatin1String("super") &&
|
||||
value != QLatin1String("sub")
|
||||
) {
|
||||
value = QString();
|
||||
qAtspiDebug() << "Unknown text-position attribute value \"" << value << "\" cannot be translated to AT-SPI.";
|
||||
}
|
||||
} else if (ia2Name == QStringLiteral("writing-mode")) {
|
||||
} else if (ia2Name == QLatin1String("writing-mode")) {
|
||||
name = QStringLiteral("direction");
|
||||
if (value == QStringLiteral("lr"))
|
||||
if (value == QLatin1String("lr"))
|
||||
value = QStringLiteral("ltr");
|
||||
else if (value == QStringLiteral("rl"))
|
||||
else if (value == QLatin1String("rl"))
|
||||
value = QStringLiteral("rtl");
|
||||
else if (value == QStringLiteral("tb")) {
|
||||
else if (value == QLatin1String("tb")) {
|
||||
// IAccessible2 docs refer to XSL, which specifies "tb" is shorthand for "tb-rl"; so at least give a hint about the horizontal direction (ATK does not support vertical direction in this attribute (yet))
|
||||
value = QStringLiteral("rtl");
|
||||
qAtspiDebug() << "writing-mode attribute value \"tb\" translated only w.r.t. horizontal direction; vertical direction ignored";
|
||||
@ -2033,9 +2033,9 @@ namespace
|
||||
value = QString();
|
||||
qAtspiDebug() << "Unknown writing-mode attribute value \"" << value << "\" cannot be translated to AT-SPI.";
|
||||
}
|
||||
} else if (ia2Name == QStringLiteral("language")) {
|
||||
} else if (ia2Name == QLatin1String("language")) {
|
||||
// OK - ATK has no docs on the format of the value, IAccessible2 has reasonable format - leave it at that now
|
||||
} else if (ia2Name == QStringLiteral("invalid")) {
|
||||
} else if (ia2Name == QLatin1String("invalid")) {
|
||||
// OK - ATK docs are vague but suggest they support the same range of values as IAccessible2
|
||||
} else {
|
||||
// attribute we know nothing about
|
||||
|
@ -1030,17 +1030,17 @@ QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const
|
||||
|
||||
QString bearer = i.value()->bearer();
|
||||
|
||||
if (bearer == QStringLiteral("gsm")) {
|
||||
if (bearer == QLatin1String("gsm")) {
|
||||
return QNetworkConfiguration::Bearer2G;
|
||||
} else if (bearer == QStringLiteral("edge")) {
|
||||
} else if (bearer == QLatin1String("edge")) {
|
||||
return QNetworkConfiguration::Bearer2G;
|
||||
} else if (bearer == QStringLiteral("umts")) {
|
||||
} else if (bearer == QLatin1String("umts")) {
|
||||
return QNetworkConfiguration::BearerWCDMA;
|
||||
} else if (bearer == QStringLiteral("hspa")
|
||||
|| bearer == QStringLiteral("hsdpa")
|
||||
|| bearer == QStringLiteral("hsupa")) {
|
||||
} else if (bearer == QLatin1String("hspa")
|
||||
|| bearer == QLatin1String("hsdpa")
|
||||
|| bearer == QLatin1String("hsupa")) {
|
||||
return QNetworkConfiguration::BearerHSPA;
|
||||
} else if (bearer == QStringLiteral("lte")) {
|
||||
} else if (bearer == QLatin1String("lte")) {
|
||||
return QNetworkConfiguration::BearerLTE;
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
|
||||
i.next();
|
||||
propertyMap.insert(i.key(),i.value());
|
||||
|
||||
if (i.key() == QStringLiteral("State")) {
|
||||
if (i.key() == QLatin1String("State")) {
|
||||
quint32 state = i.value().toUInt();
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED
|
||||
|| state == NM_DEVICE_STATE_DISCONNECTED
|
||||
@ -223,7 +223,7 @@ void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
|
||||
Q_EMIT propertiesChanged(map);
|
||||
Q_EMIT stateChanged(state);
|
||||
}
|
||||
} else if (i.key() == QStringLiteral("ActiveConnections")) {
|
||||
} else if (i.key() == QLatin1String("ActiveConnections")) {
|
||||
Q_EMIT propertiesChanged(map);
|
||||
}
|
||||
}
|
||||
@ -418,7 +418,7 @@ void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map)
|
||||
QMapIterator<QString, QVariant> i(map);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.key() == QStringLiteral("AvailableConnections")) { //Device
|
||||
if (i.key() == QLatin1String("AvailableConnections")) { //Device
|
||||
const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>();
|
||||
QDBusObjectPath path;
|
||||
QStringList paths;
|
||||
@ -514,9 +514,8 @@ void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant>
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
propertyMap.insert(i.key(),i.value());
|
||||
if (i.key() == QStringLiteral("Carrier")) {
|
||||
if (i.key() == QLatin1String("Carrier"))
|
||||
Q_EMIT carrierChanged(i.value().toBool());
|
||||
}
|
||||
}
|
||||
Q_EMIT propertiesChanged(map);
|
||||
}
|
||||
@ -693,9 +692,8 @@ void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVarian
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
propertyMap.insert(i.key(),i.value());
|
||||
if (i.key() == QStringLiteral("ActiveAccessPoint")) { //DeviceWireless
|
||||
if (i.key() == QLatin1String("ActiveAccessPoint")) //DeviceWireless
|
||||
Q_EMIT propertiesChanged(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1051,7 +1049,7 @@ void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
propertyMap.insert(i.key(),i.value());
|
||||
if (i.key() == QStringLiteral("State")) {
|
||||
if (i.key() == QLatin1String("State")) {
|
||||
quint32 state = i.value().toUInt();
|
||||
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
||||
|| state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
|
||||
|
@ -86,9 +86,9 @@ QMimeData *QHaikuClipboard::mimeData(QClipboard::Mode mode)
|
||||
const status_t status = clipboard->FindData(name, B_MIME_TYPE, &data, &dataLen);
|
||||
if (dataLen && (status == B_OK)) {
|
||||
const QString format = QString::fromLatin1(name);
|
||||
if (format == QStringLiteral("text/plain")) {
|
||||
if (format == QLatin1String("text/plain")) {
|
||||
m_systemMimeData->setText(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
|
||||
} else if (format == QStringLiteral("text/html")) {
|
||||
} else if (format == QLatin1String("text/html")) {
|
||||
m_systemMimeData->setHtml(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
|
||||
} else {
|
||||
m_systemMimeData->setData(format, QByteArray(reinterpret_cast<const char*>(data), dataLen));
|
||||
|
@ -1613,7 +1613,7 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request)
|
||||
if (fam.isEmpty())
|
||||
fam = QStringLiteral("MS Sans Serif");
|
||||
|
||||
if ((fam == QStringLiteral("MS Sans Serif"))
|
||||
if (fam == QLatin1String("MS Sans Serif")
|
||||
&& (request.style == QFont::StyleItalic || (-lf.lfHeight > 18 && -lf.lfHeight != 24))) {
|
||||
fam = QStringLiteral("Arial"); // MS Sans Serif has bearing problems in italic, and does not scale
|
||||
}
|
||||
|
@ -1145,7 +1145,7 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject *
|
||||
{
|
||||
Q_UNUSED(preferredType);
|
||||
QVariant result;
|
||||
if (mimeType != QStringLiteral("application/x-qt-image"))
|
||||
if (mimeType != QLatin1String("application/x-qt-image"))
|
||||
return result;
|
||||
//Try to convert from a format which has more data
|
||||
//DIBV5, use only if its is not synthesized
|
||||
|
@ -639,7 +639,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
|
||||
QString glIntegrationName = QString::fromLocal8Bit(qgetenv("QT_XCB_GL_INTEGRATION"));
|
||||
if (!glIntegrationName.isEmpty()) {
|
||||
qCDebug(QT_XCB_GLINTEGRATION) << "QT_XCB_GL_INTEGRATION is set to" << glIntegrationName;
|
||||
if (glIntegrationName != QStringLiteral("none")) {
|
||||
if (glIntegrationName != QLatin1String("none")) {
|
||||
glIntegrationNames.removeAll(glIntegrationName);
|
||||
glIntegrationNames.prepend(glIntegrationName);
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
QPlatformPrinterSupport *QCocoaPrinterSupportPlugin::create(const QString &key)
|
||||
{
|
||||
if (key.compare(key, QStringLiteral("cocoaprintersupport"), Qt::CaseInsensitive) != 0)
|
||||
if (key.compare(key, QLatin1String("cocoaprintersupport"), Qt::CaseInsensitive) != 0)
|
||||
return 0;
|
||||
QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance());
|
||||
if (!app)
|
||||
|
@ -1094,7 +1094,7 @@ void Configure::parseCmdLine()
|
||||
if (i == argCount)
|
||||
break;
|
||||
QString mod = configCmdLine.at(i);
|
||||
if (!mod.startsWith(QStringLiteral("qt")))
|
||||
if (!mod.startsWith(QLatin1String("qt")))
|
||||
mod.insert(0, QStringLiteral("qt"));
|
||||
if (!QFileInfo(sourcePath + "/../" + mod).isDir()) {
|
||||
cout << "Attempting to skip non-existent module " << mod << "." << endl;
|
||||
@ -3810,7 +3810,7 @@ void Configure::displayConfig()
|
||||
env = "Unset";
|
||||
sout << " PATH=\n " << env << endl;
|
||||
|
||||
if (dictionary[QStringLiteral("EDITION")] != QStringLiteral("OpenSource")) {
|
||||
if (dictionary[QStringLiteral("EDITION")] != QLatin1String("OpenSource")) {
|
||||
QString l1 = dictionary[ "LICENSEE" ];
|
||||
QString l2 = dictionary[ "LICENSEID" ];
|
||||
QString l3 = dictionary["EDITION"] + ' ' + "Edition";
|
||||
|
@ -389,11 +389,11 @@ QString CodeGenerator::passByType(const Argument &arg) const
|
||||
|
||||
QString CodeGenerator::safeArgumentName(const QString& arg) const
|
||||
{
|
||||
if (arg == QStringLiteral("near")) // MS Windows defines near and far
|
||||
if (arg == QLatin1String("near")) // MS Windows defines near and far
|
||||
return QStringLiteral("nearVal");
|
||||
else if (arg == QStringLiteral("far"))
|
||||
else if (arg == QLatin1String("far"))
|
||||
return QStringLiteral("farVal");
|
||||
else if (arg == QStringLiteral("d"))
|
||||
else if (arg == QLatin1String("d"))
|
||||
return QStringLiteral("dd"); // Don't shadow d pointer
|
||||
else
|
||||
return arg;
|
||||
@ -810,7 +810,7 @@ void CodeGenerator::writeInlineFunction(QTextStream &stream, const QString &clas
|
||||
argumentNames.append(safeArgumentName(arg.name));
|
||||
QString argNames = argumentNames.join(", ");
|
||||
|
||||
if (f.returnType == QStringLiteral("void"))
|
||||
if (f.returnType == QLatin1String("void"))
|
||||
stream << QString(QStringLiteral(" %1->%2(%3);")).arg(backendVar).arg(f.name).arg(argNames) << endl;
|
||||
else
|
||||
stream << QString(QStringLiteral(" return %1->%2(%3);")).arg(backendVar).arg(f.name).arg(argNames) << endl;
|
||||
|
@ -80,7 +80,7 @@ bool LegacySpecParser::parseTypeMap()
|
||||
while (!stream.atEnd()) {
|
||||
QString line = stream.readLine();
|
||||
|
||||
if (line.startsWith(QStringLiteral("#")))
|
||||
if (line.startsWith(QLatin1Char('#')))
|
||||
continue;
|
||||
|
||||
if (typeMapRegExp.indexIn(line) != -1) {
|
||||
@ -88,7 +88,7 @@ bool LegacySpecParser::parseTypeMap()
|
||||
QString value = typeMapRegExp.cap(2).simplified();
|
||||
|
||||
// Special case for void
|
||||
if (value == QStringLiteral("*"))
|
||||
if (value == QLatin1String("*"))
|
||||
value = QStringLiteral("void");
|
||||
|
||||
m_typeMap.insert(key, value);
|
||||
@ -144,7 +144,7 @@ void LegacySpecParser::parseFunctions(QTextStream &stream)
|
||||
// extension. These functions should be added to the DSA extension rather
|
||||
// than the core functionality. The core will already contain non-DSA
|
||||
// versions of these functions.
|
||||
if (acceptCurrentFunctionInCore && currentFunction.name.endsWith(QStringLiteral("EXT"))) {
|
||||
if (acceptCurrentFunctionInCore && currentFunction.name.endsWith(QLatin1String("EXT"))) {
|
||||
acceptCurrentFunctionInCore = false;
|
||||
acceptCurrentFunctionInExtension = true;
|
||||
currentCategory = QStringLiteral("EXT_direct_state_access");
|
||||
@ -191,9 +191,9 @@ void LegacySpecParser::parseFunctions(QTextStream &stream)
|
||||
arg.type = m_typeMap.value(type);
|
||||
|
||||
QString direction = argumentRegExp.cap(3);
|
||||
if (direction == QStringLiteral("in")) {
|
||||
if (direction == QLatin1String("in")) {
|
||||
arg.direction = Argument::In;
|
||||
} else if (direction == QStringLiteral("out")) {
|
||||
} else if (direction == QLatin1String("out")) {
|
||||
arg.direction = Argument::Out;
|
||||
} else {
|
||||
qWarning() << "Invalid argument direction found:" << direction;
|
||||
@ -201,11 +201,11 @@ void LegacySpecParser::parseFunctions(QTextStream &stream)
|
||||
}
|
||||
|
||||
QString mode = argumentRegExp.cap(4);
|
||||
if (mode == QStringLiteral("value")) {
|
||||
if (mode == QLatin1String("value")) {
|
||||
arg.mode = Argument::Value;
|
||||
} else if (mode == QStringLiteral("array")) {
|
||||
} else if (mode == QLatin1String("array")) {
|
||||
arg.mode = Argument::Array;
|
||||
} else if (mode == QStringLiteral("reference")) {
|
||||
} else if (mode == QLatin1String("reference")) {
|
||||
arg.mode = Argument::Reference;
|
||||
} else {
|
||||
qWarning() << "Invalid argument mode found:" << mode;
|
||||
@ -246,7 +246,7 @@ void LegacySpecParser::parseFunctions(QTextStream &stream)
|
||||
// Extract the OpenGL version in which this function was deprecated.
|
||||
// If it is OpenGL 3.1 then it must be a compatibility profile function
|
||||
QString deprecatedVersion = deprecatedRegExp.cap(1).simplified();
|
||||
if (deprecatedVersion == QStringLiteral("3.1") && !inDeprecationException(currentFunction.name))
|
||||
if (deprecatedVersion == QLatin1String("3.1") && !inDeprecationException(currentFunction.name))
|
||||
currentVersionProfile.profile = VersionProfile::CompatibilityProfile;
|
||||
|
||||
} else if (categoryRegExp.indexIn(line) != -1) {
|
||||
@ -301,5 +301,5 @@ void LegacySpecParser::parseFunctions(QTextStream &stream)
|
||||
|
||||
bool LegacySpecParser::inDeprecationException(const QString &functionName) const
|
||||
{
|
||||
return (functionName == QStringLiteral("TexImage3D"));
|
||||
return functionName == QLatin1String("TexImage3D");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user