diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-07-10 06:34:27 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-07-10 06:34:27 +0000 |
| commit | eb54b5973e2bd1cb174140d330d26cc3e1d7b063 (patch) | |
| tree | 3fded61f69745f196382345eb782ae664d53262e /clang/Lex/Lexer.cpp | |
| parent | 03f83485bd1855bd72c4eeedf7ceec3ae85aedd1 (diff) | |
| download | bcm5719-llvm-eb54b5973e2bd1cb174140d330d26cc3e1d7b063.tar.gz bcm5719-llvm-eb54b5973e2bd1cb174140d330d26cc3e1d7b063.zip | |
Add simple optimization: check for (and skip) spaces and tabs immediately
before lexing a token. This speeds the common case where tokens are
separated by small amount of whitespace. This makes a slight but
reproducible positive effect lexing a preprocessed carbon.h.
llvm-svn: 38691
Diffstat (limited to 'clang/Lex/Lexer.cpp')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 9cf0dae0a0c..967d4e76758 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -928,6 +928,15 @@ LexNextToken: // CurPtr - Cache BufferPtr in an automatic variable. const char *CurPtr = BufferPtr; + // Small amounts of horizontal whitespace is very common between tokens. + if ((*CurPtr == ' ') || (*CurPtr == '\t')) { + ++CurPtr; + while ((*CurPtr == ' ') || (*CurPtr == '\t')) + ++CurPtr; + BufferPtr = CurPtr; + Result.SetFlag(LexerToken::LeadingSpace); + } + unsigned SizeTmp, SizeTmp2; // Temporaries for use in cases below. // Read a character, advancing over it. |

