diff options
Diffstat (limited to 'src/tools/moc/preprocessor.cpp')
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index a2a1a958cf..a47896d722 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) { @@ -1217,6 +1222,10 @@ Symbols Preprocessor::preprocessed(const QByteArray &filename, QFile *file) // phase 3: preprocess conditions and substitute macros Symbols result; + // Preallocate some space to speed up the code below. + // The magic value was found by logging the final size + // and calculating an average when running moc over FOSS projects. + result.reserve(file->size() / 300000); preprocess(filename, result); mergeStringLiterals(&result); |