Commit 2d500117 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Eike Ziller
Browse files

C++: pre-allocate the output buffer.

This prevents a whole lot of re-allocations when the output byte array
needs to grow. It also prevents some heap fragmentation for big files.

Because the preprocessed output is short lived (it will be parsed
immediately after, and then discarded), it is not squeezed to the
minimal size. This would result in another allocation.

Change-Id: I4974be5144f88cdfc4ddc9d8330200725aa90803
Reviewed-by: default avatarhjk <>
Reviewed-by: default avatarEike Ziller <>
parent 376a90e0
......@@ -702,6 +702,7 @@ QByteArray Preprocessor::run(const QString &fileName,
QByteArray preprocessed, includeGuardMacroName;
preprocessed.reserve(source.size() * 2); // multiply by 2 because we insert #gen lines.
preprocess(fileName, source, &preprocessed, &includeGuardMacroName, noLines,
markGeneratedTokens, false);
if (!includeGuardMacroName.isEmpty())
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment