[cfe-commits] r61168 - /cfe/trunk/include/clang/Lex/PTHLexer.h
Ted Kremenek
kremenek at apple.com
Wed Dec 17 15:08:36 PST 2008
Author: kremenek
Date: Wed Dec 17 17:08:31 2008
New Revision: 61168
URL: http://llvm.org/viewvc/llvm-project?rev=61168&view=rev
Log:
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().
Modified:
cfe/trunk/include/clang/Lex/PTHLexer.h
Modified: cfe/trunk/include/clang/Lex/PTHLexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PTHLexer.h?rev=61168&r1=61167&r2=61168&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PTHLexer.h (original)
+++ cfe/trunk/include/clang/Lex/PTHLexer.h Wed Dec 17 17:08:31 2008
@@ -76,8 +76,13 @@
/// 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.
More information about the cfe-commits
mailing list