forked from OSchip/llvm-project
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
This commit is contained in:
parent
03f83485bd
commit
eb54b5973e
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue