Optimize moc: Implement fast operator== for Symbols.

Previously, this allocated temporary QByteArrays in the frequent
QVector<Symbols>::indexOf calls (macro.arguments.indexOf(s)).

Now, the we reuse the fast SubArray::operator== implementation.

Change-Id: Idbc6e3cf5fd353e8e36d51ba88d31e4c3bfd121d
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Milian Wolff 2015-05-30 23:12:44 +02:00
parent 58f0b6b5a8
commit a576ef4c3d

View File

@ -113,8 +113,11 @@ struct Symbol
Token token;
inline QByteArray lexem() const { return lex.mid(from, len); }
inline QByteArray unquotedLexem() const { return lex.mid(from+1, len-2); }
inline operator QByteArray() const { return lex.mid(from, len); }
inline operator SubArray() const { return SubArray(lex, from, len); }
bool operator==(const Symbol& o) const
{
return SubArray(lex, from, len) == SubArray(o.lex, o.from, o.len);
}
QByteArray lex;
int from, len;