Avoid calling getSpelling at all for identifiers, which are
trivial to handle and very very common. This speeds up -E on
447.dealII by 2.5%
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40422 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index a7d55df..d1f1cef 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -517,7 +517,11 @@
OutputChar(' ');
}
- if (Tok.getLength() < 256) {
+ if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
+ const char *Str = II->getName();
+ unsigned Len = Tok.needsCleaning() ? strlen(Str) : Tok.getLength();
+ OutputString(Str, Len);
+ } else if (Tok.getLength() < 256) {
const char *TokPtr = Buffer;
unsigned Len = PP.getSpelling(Tok, TokPtr);
OutputString(TokPtr, Len);