summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2015-05-30 23:10:00 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-12-12 09:07:06 +0000
commit6cc79ad9947bc353dbc7decd91c462c9b104cf92 (patch)
tree17613f2d008e89bc6c5521ee6e51dba0df747ee4 /src/tools
parentb894dfe311bb90210af102a59b3a09f587bb7442 (diff)
Optimize moc: Preallocate space for list of preprocessed symbols.
Without this, the symbol list is frequently reallocated. The value is a guestimate. It corresponds to a block of memory with the size 262144 * 3 * 8 byte = ca. 6.3 megabytes on a 64 bit machine. Looking at the final size of the symbol list, this seems to fit the common case nicely. Change-Id: Ib546a1ea479f2c6d8ab57be783cdf630f9b54f77 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/preprocessor.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 590f17c24f..a47896d722 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -1222,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);