From: Ted Kremenek Date: Wed, 17 Dec 2008 23:08:31 +0000 (+0000) Subject: PTHLexer::isNextPPTokenLParen() no longer calls GetToken() and just reads the token... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=daeee815169f37f2a49f80af7bd104722672ad97;p=clang PTHLexer::isNextPPTokenLParen() no longer calls GetToken() and just reads the token kind from the token data buffer. This results in a minor speedup and reduces the dependency on GetToken(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61168 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/PTHLexer.h b/include/clang/Lex/PTHLexer.h index 7654a39653..34e0b8a9fb 100644 --- a/include/clang/Lex/PTHLexer.h +++ b/include/clang/Lex/PTHLexer.h @@ -76,8 +76,13 @@ public: /// tok::l_paren token, 0 if it is something else and 2 if there are no more /// tokens controlled by this lexer. unsigned isNextPPTokenLParen() { - return AtLastToken() ? 2 : GetToken().is(tok::l_paren); - } + // isNextPPTokenLParen is not on the hot path, and all we care about is + // whether or not we are at a token with kind tok::eof or tok::l_paren. + // Just read the first byte from the current token pointer to determine + // its kind. + tok::TokenKind x = (tok::TokenKind) (uint8_t) *CurPtr; + return x == tok::eof ? 2 : x == tok::l_paren; + } /// IndirectLex - An indirect call to 'Lex' that can be invoked via /// the PreprocessorLexer interface.