Commit 6fa81bed authored by Milian Wolff's avatar Milian Wolff
Browse files

Optimize: use QVarLengthArray<QChar> instead of QList<QChar>

The latter would put the 2byte QChar into the 8byte QList slots,
and would require a memory allocation for the buffer too. With a
QVarLengthArray we get zero allocations for the common case and
better cache utilization as we don't suffer from the padding issue.
parent 774ff955
......@@ -10,6 +10,7 @@
#include <QString>
#include <QStringList>
#include <QVarLengthArray>
namespace {
template <typename T>
......@@ -130,7 +131,7 @@ bool parenFits(QChar c1, QChar c2)
int findClose(const QString& str, int pos)
int depth = 0;
QList<QChar> st;
QVarLengthArray<QChar, 16> st;
QChar last = QLatin1Char(' ');
for (int a = pos; a < str.length(); a++) {
......@@ -142,7 +143,7 @@ int findClose(const QString& str, int pos)
case '(':
case '[':
case '{':
st.insert(0, str[a]);
case '>':
......@@ -156,7 +157,7 @@ int findClose(const QString& str, int pos)
case '}':
if (!st.isEmpty() && parenFits(st.front(), str[a])) {
case '"':
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