summaryrefslogtreecommitdiffstats
path: root/src/tools/moc
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2015-05-30 23:20:33 +0200
committerMilian Wolff <milian.wolff@kdab.com>2015-07-14 22:09:28 +0000
commitf337e22401f5f4efa696d07090b2e4ba5a245c27 (patch)
tree80f4bc96c76dbe0f1261d6fe253f1311154c6164 /src/tools/moc
parenta545715c8317f79699610a58e15f4c48e9c1501e (diff)
Optimize moc: Remove another temporary list allocation.
In the common case, macroExpandIdentifier was called in the "not a macro" case, and a temporary vector with a single item was allocated. Now, we catch this common case at the caller site and put the single item directly into the result set, bypassing the temporary list. Change-Id: I71d92afc486ccdaae5930405d028f53f48073b8c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools/moc')
-rw-r--r--src/tools/moc/preprocessor.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 14850b3e0c..17274f0877 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -547,7 +547,10 @@ void Preprocessor::macroExpand(Symbols *into, Preprocessor *that, Symbols &toExp
Symbols newSyms = macroExpandIdentifier(that, symbols, lineNum, &macro);
if (macro.isEmpty()) {
- *into += newSyms;
+ // not a macro
+ Symbol s = symbols.symbol();
+ s.lineNum = lineNum;
+ *into += s;
} else {
SafeSymbols sf;
sf.symbols = newSyms;
@@ -573,10 +576,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
// not a macro
if (s.token != PP_IDENTIFIER || !that->macros.contains(s) || symbols.dontReplaceSymbol(s.lexem())) {
- Symbols syms;
- syms += s;
- syms.last().lineNum = lineNum;
- return syms;
+ return Symbols();
}
const Macro &macro = that->macros.value(s);