From f337e22401f5f4efa696d07090b2e4ba5a245c27 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sat, 30 May 2015 23:20:33 +0200 Subject: 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) --- src/tools/moc/preprocessor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/tools/moc/preprocessor.cpp') 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, ¯o); 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 ¯o = that->macros.value(s); -- cgit v1.2.3