Skip to content

Commit

Permalink
[clang-format][NFC] Improve efficiency of isFunctionDeclarationName
Browse files Browse the repository at this point in the history
Return immediately in isFunctionDeclarationName() if the token is neither a
keyword nor an identifier.
  • Loading branch information
owenca committed Jul 7, 2023
1 parent 11ad540 commit 0556ab3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3129,6 +3129,9 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
const AnnotatedLine &Line) {
assert(Current.Previous);
if (!Current.Tok.getIdentifierInfo())
return false;

auto skipOperatorName = [](const FormatToken *Next) -> const FormatToken * {
for (; Next; Next = Next->Next) {
if (Next->is(TT_OverloadedOperatorLParen))
Expand Down

0 comments on commit 0556ab3

Please sign in to comment.