forked from OSchip/llvm-project
use efficient form of getSpelling, this speeds up -dM by 16%.
llvm-svn: 64244
This commit is contained in:
parent
654e47f366
commit
8ac63738b4
|
@ -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";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue