summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-27 03:42:15 +0000
committerChris Lattner <sabre@nondot.org>2006-07-27 03:42:15 +0000
commitb57aa46e41f9f90c15cf3fcaba0823b4981bb3ea (patch)
tree85a8f020dfbfcb58e5f40094913ab20253d21316
parent7a4af3b73ddb9dc9dfc5441a51b64bcad588ea74 (diff)
downloadbcm5719-llvm-b57aa46e41f9f90c15cf3fcaba0823b4981bb3ea.tar.gz
bcm5719-llvm-b57aa46e41f9f90c15cf3fcaba0823b4981bb3ea.zip
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
-rw-r--r--clang/Lex/MacroExpander.cpp8
1 files changed, 4 insertions, 4 deletions
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<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;
}
OpenPOWER on IntegriCloud