diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2015-05-30 23:08:49 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2015-09-14 08:26:13 +0000 |
commit | 5b0f59c73d46bae10c5c22b270c0f7ef6ffff20c (patch) | |
tree | b6c64bdff34556a615b280eda5db94af1a538d35 /src/tools | |
parent | 978ee4e60e2e1694ac46512072b1330dd2f69031 (diff) |
Optimize moc: Preallocate some space for tokenization results.
The value was found by looking at the common ratio between
input size and final size of the result list.
Change-Id: I5762c15156afad4a7b8c1538e886058b3b5b0673
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index d036c40f35..0a80c0242b 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -154,6 +154,11 @@ bool Preprocessor::skipBranch() Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocessor::TokenizeMode mode) { Symbols symbols; + // Preallocate some space to speed up the code below. + // The magic divisor value was found by calculating the average ratio between + // input size and the final size of symbols. + // This yielded a value of 16.x when compiling Qt Base. + symbols.reserve(input.size() / 16); const char *begin = input.constData(); const char *data = begin; while (*data) { |