Commit 878c681a authored by Milian Wolff's avatar Milian Wolff
Browse files

Only call str.size() at most once in findCommaOrEnd

Basic rule for clean code, performance wise it's probably only going
to be noticeable (barely) in debug builds. For release builds the
compiler should be able to hoist this out.
parent d6cd4569
Pipeline #244253 passed with stage
in 24 minutes and 28 seconds
......@@ -225,13 +225,10 @@ int findClose(const QString& str, int pos)
int findCommaOrEnd(const QString& str, int pos, QChar validEnd)
{
if (pos == str.size()) {
return pos;
}
Q_ASSERT(pos >= 0 && pos < str.size());
const auto size = str.size();
Q_ASSERT(pos >= 0 && pos <= size);
for (int a = pos; a < str.length(); a++) {
for (int a = pos; a < size; a++) {
switch (str[a].unicode()) {
case '"':
case '\'':
......@@ -246,7 +243,7 @@ int findCommaOrEnd(const QString& str, int pos, QChar validEnd)
case '{':
a = findClose(str, a);
if (a == -1)
return str.length();
return size;
break;
case '>':
if (isOperator(str, a) || isArrowOperator(str, a))
......@@ -264,7 +261,7 @@ int findCommaOrEnd(const QString& str, int pos, QChar validEnd)
}
}
return str.length();
return size;
}
QString reduceWhiteSpace(const QString& str_)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment