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
This commit is contained in:
Chris Lattner 2006-07-27 03:42:15 +00:00
parent 7a4af3b73d
commit b57aa46e41
1 changed files with 4 additions and 4 deletions

View File

@ -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<LexerToken> ResultToks;
SmallVector<LexerToken, 128> 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;
}