From: Chris Lattner Date: Mon, 23 Jul 2007 06:14:36 +0000 (+0000) Subject: Avoid calling getSpelling at all for identifiers, which are X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2933f41ed59a8bf1866292cb82e16c8b10dc6651;p=clang 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 a7d55df34b..d1f1cef985 100644 --- a/Driver/PrintPreprocessedOutput.cpp +++ b/Driver/PrintPreprocessedOutput.cpp @@ -517,7 +517,11 @@ void clang::DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, 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);