From 5b0f59c73d46bae10c5c22b270c0f7ef6ffff20c Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sat, 30 May 2015 23:08:49 +0200 Subject: 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) --- src/tools/moc/preprocessor.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/tools/moc/preprocessor.cpp') diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index d036c40f354..0a80c0242bf 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) { -- cgit v1.2.3