diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-10 22:16:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-10 22:16:03 +0000 |
commit | eb213da2fd4680a3e1b662eba0de3e949f75aa7b (patch) | |
tree | a1c720dd546b679cb402ecae19f9574f7104ac61 | |
parent | 0bfe54fdc83b7b4e37c40e652d86d15aa89885b2 (diff) |
use efficient form of getSpelling, this speeds up -dM by 16%.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64244 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Driver/PrintPreprocessedOutput.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp index 8bd4e96ae3..7aceb7a750 100644 --- a/Driver/PrintPreprocessedOutput.cpp +++ b/Driver/PrintPreprocessedOutput.cpp @@ -582,11 +582,19 @@ static void PrintMacroDefinition(IdentifierInfo &II, const MacroInfo &MI, if (MI.tokens_empty() || !MI.tokens_begin()->hasLeadingSpace()) OS << ' '; + llvm::SmallVector<char, 128> SpellingBuffer; + for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end(); I != E; ++I) { if (I->hasLeadingSpace()) OS << ' '; - OS << PP.getSpelling(*I); + + // Make sure we have enough space in the spelling buffer. + if (I->getLength() < SpellingBuffer.size()) + SpellingBuffer.resize(I->getLength()); + const char *Buffer = &SpellingBuffer[0]; + unsigned SpellingLen = PP.getSpelling(*I, Buffer); + OS.write(Buffer, SpellingLen); } OS << "\n"; } |