[Lexer] Speedup LexTokenInternal
Only reset "NeedsCleaning" flag in case of re-entrant call. Do not needlessly blank IdentifierInfo. This information will be set once the token type is picked. This yields a nice 1% speedup when pre-processing sqlite amalgamation through: valgrind --tool=callgrind ./bin/clang -E sqlite3.c -o/dev/null Differential Revision: https://reviews.llvm.org/D137960
This commit is contained in:
parent
462e461666
commit
cb3f8d53e6
|
@ -175,6 +175,8 @@ public:
|
|||
Loc = SourceLocation().getRawEncoding();
|
||||
}
|
||||
|
||||
bool hasPtrData() const { return PtrData != nullptr; }
|
||||
|
||||
IdentifierInfo *getIdentifierInfo() const {
|
||||
assert(isNot(tok::raw_identifier) &&
|
||||
"getIdentifierInfo() on a tok::raw_identifier token!");
|
||||
|
|
|
@ -3516,10 +3516,9 @@ bool Lexer::Lex(Token &Result) {
|
|||
/// token, not a normal token, as such, it is an internal interface. It assumes
|
||||
/// that the Flags of result have been cleared before calling this.
|
||||
bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
|
||||
LexNextToken:
|
||||
// New token, can't need cleaning yet.
|
||||
Result.clearFlag(Token::NeedsCleaning);
|
||||
Result.setIdentifierInfo(nullptr);
|
||||
LexStart:
|
||||
assert(!Result.needsCleaning() && "Result doesn't need cleaning");
|
||||
assert(!Result.hasPtrData() && "Result has been reset");
|
||||
|
||||
// CurPtr - Cache BufferPtr in an automatic variable.
|
||||
const char *CurPtr = BufferPtr;
|
||||
|
@ -4301,6 +4300,10 @@ HandleDirective:
|
|||
|
||||
// We parsed the directive; lex a token with the new state.
|
||||
return false;
|
||||
|
||||
LexNextToken:
|
||||
Result.clearFlag(Token::NeedsCleaning);
|
||||
goto LexStart;
|
||||
}
|
||||
|
||||
const char *Lexer::convertDependencyDirectiveToken(
|
||||
|
|
Loading…
Reference in New Issue