summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-19 11:49:37 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-28 18:00:47 +0000
commit0f27d11285bbc22c4f440315ba3a9b7627fc449b (patch)
tree3e384b64c92b33cd6475bf7e91d659ac67f71463 /util
parent58f8dd4f92e0e647ed530554d7edf3d1a901f552 (diff)
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>
Diffstat (limited to 'util')
-rw-r--r--util/glgen/codegenerator.cpp8
-rw-r--r--util/glgen/legacyspecparser.cpp20
2 files changed, 14 insertions, 14 deletions
diff --git a/util/glgen/codegenerator.cpp b/util/glgen/codegenerator.cpp
index f590e42960..15db4d0a83 100644
--- a/util/glgen/codegenerator.cpp
+++ b/util/glgen/codegenerator.cpp
@@ -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;
diff --git a/util/glgen/legacyspecparser.cpp b/util/glgen/legacyspecparser.cpp
index fc34eca80c..77b106bd5d 100644
--- a/util/glgen/legacyspecparser.cpp
+++ b/util/glgen/legacyspecparser.cpp
@@ -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");
}