Skip to content

Commit 4f05802

Browse files
committed
[Lexer] Micro optimization for getTokenAt()
lex() invokes lexImpl(). It doesn't need to lex next token.
1 parent 4381735 commit 4f05802

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/Parse/Lexer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ Token Lexer::getTokenAt(SourceLoc Loc) {
267267
HashbangMode::Allowed, CommentRetentionMode::None,
268268
TriviaRetentionMode::WithoutTrivia);
269269
L.restoreState(State(Loc));
270-
Token Result;
271-
L.lex(Result);
272-
return Result;
270+
return L.peekNextToken();
273271
}
274272

275273
void Lexer::formToken(tok Kind, const char *TokStart) {

0 commit comments

Comments
 (0)