diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-03-05 09:56:08 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-04-08 11:20:55 +0200 |
commit | 2d500117163811a7059a3165a9b80f046a292b18 (patch) | |
tree | d285b7af7d7c28082f6e5f61dd08d19b9420e931 /src/libs/cplusplus/pp-engine.cpp | |
parent | 376a90e028c82577ac084974e98465934bbc6866 (diff) | |
download | qt-creator-2d500117163811a7059a3165a9b80f046a292b18.tar.gz |
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: hjk <hjk121@nokiamail.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/libs/cplusplus/pp-engine.cpp')
-rw-r--r-- | src/libs/cplusplus/pp-engine.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 1c45e61e2a..980f59c0a2 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -702,6 +702,7 @@ QByteArray Preprocessor::run(const QString &fileName, m_scratchBuffer.clear(); 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()) |