From b57aa46e41f9f90c15cf3fcaba0823b4981bb3ea Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 27 Jul 2006 03:42:15 +0000 Subject: Switch ExpandFunctionArguments to use a smallvector instead of a vector, speeding up my macro expansion torture test from .75s to .5s (33%!) llvm-svn: 38758 --- clang/Lex/MacroExpander.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'clang/Lex/MacroExpander.cpp') diff --git a/clang/Lex/MacroExpander.cpp b/clang/Lex/MacroExpander.cpp index 8fb569afd37..3a2f9da90f3 100644 --- a/clang/Lex/MacroExpander.cpp +++ b/clang/Lex/MacroExpander.cpp @@ -16,6 +16,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Config/Alloca.h" using namespace llvm; using namespace clang; @@ -285,7 +286,7 @@ MacroExpander::~MacroExpander() { /// Expand the arguments of a function-like macro so that we can quickly /// return preexpanded tokens from MacroTokens. void MacroExpander::ExpandFunctionArguments() { - std::vector ResultToks; + SmallVector ResultToks; // Loop through the MacroTokens tokens, expanding them into ResultToks. Keep // track of whether we change anything. If not, no need to keep them. If so, @@ -354,8 +355,7 @@ void MacroExpander::ExpandFunctionArguments() { if (ResultArgToks->getKind() != tok::eof) { unsigned FirstResult = ResultToks.size(); unsigned NumToks = MacroArgs::getArgLength(ResultArgToks); - ResultToks.insert(ResultToks.end(), ResultArgToks, - ResultArgToks+NumToks); + ResultToks.append(ResultArgToks, ResultArgToks+NumToks); // If any tokens were substituted from the argument, the whitespace // before the first token should match the whitespace of the arg @@ -372,7 +372,7 @@ void MacroExpander::ExpandFunctionArguments() { unsigned NumToks = MacroArgs::getArgLength(ArgToks); if (NumToks) { // Not an empty argument? - ResultToks.insert(ResultToks.end(), ArgToks, ArgToks+NumToks); + ResultToks.append(ArgToks, ArgToks+NumToks); continue; } -- cgit v1.2.3