aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-17 23:08:31 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-17 23:08:31 +0000
commitdaeee815169f37f2a49f80af7bd104722672ad97 (patch)
treec01ebf5b452bedf9e2b26e6644c6215cf2576e04
parent9103bb27f4eefa0e0d7935387750e3aca24abc49 (diff)
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
-rw-r--r--include/clang/Lex/PTHLexer.h9
1 files changed, 7 insertions, 2 deletions
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.