From: Chris Lattner Date: Mon, 23 Jul 2007 05:18:42 +0000 (+0000) Subject: If a token doesn't need cleaning, we can get its first character X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b19f5e8415223940c014187d45e75ef4aeff7678;p=clang If a token doesn't need cleaning, we can get its first character 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 --- diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp index 706247877c..cb8bfec3c4 100644 --- a/Driver/PrintPreprocessedOutput.cpp +++ b/Driver/PrintPreprocessedOutput.cpp @@ -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);