]> granicus.if.org Git - clang/commitdiff
If a token doesn't need cleaning, we can get its first character
authorChris Lattner <sabre@nondot.org>
Mon, 23 Jul 2007 05:18:42 +0000 (05:18 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 Jul 2007 05:18:42 +0000 (05:18 +0000)
without having to get the whole token.  This speeds up -E on
447.dealII by 1.8%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40420 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/PrintPreprocessedOutput.cpp

index 706247877c5fbfc658e910eae8ec26536cf79089..cb8bfec3c4542bc864edfebf55473cd62a2bdb33 100644 (file)
@@ -332,6 +332,10 @@ bool PrintPPOutputPPCallbacks::AvoidConcat(const Token &PrevTok,
   if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
     // Avoid spelling identifiers, the most common form of token.
     FirstChar = II->getName()[0];
+  } else if (!Tok.needsCleaning()) {
+    SourceManager &SrcMgr = PP.getSourceManager();
+    FirstChar =
+      *SrcMgr.getCharacterData(SrcMgr.getPhysicalLoc(Tok.getLocation()));
   } else if (Tok.getLength() < 256) {
     const char *TokPtr = Buffer;
     PP.getSpelling(Tok, TokPtr);