Skip to content

Commit 3a3b0fd

Browse files
committed
small Tokenizer::isFunctionHead() optimization
1 parent 0ff3dd2 commit 3a3b0fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/tokenlist.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,11 +2321,11 @@ const Token * TokenList::isFunctionHead(const Token *tok, const std::string &end
23212321
if (Token::Match(tok, ") ;|{|[")) {
23222322
tok = tok->next();
23232323
while (tok && tok->str() == "[" && tok->link()) {
2324-
if (endsWith.find(tok->str()) != std::string::npos)
2324+
if (endsWith.find('[') != std::string::npos)
23252325
return tok;
23262326
tok = tok->link()->next();
23272327
}
2328-
return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
2328+
return (tok && tok->str().length() == 1 && endsWith.find(tok->str()[0]) != std::string::npos) ? tok : nullptr;
23292329
}
23302330
if (tok->isCpp() && tok->str() == ")") {
23312331
tok = tok->next();
@@ -2360,7 +2360,7 @@ const Token * TokenList::isFunctionHead(const Token *tok, const std::string &end
23602360
}
23612361
if (tok && tok->str() == ":" && !Token::Match(tok->next(), "%name%|::"))
23622362
return nullptr;
2363-
return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
2363+
return (tok && tok->str().length() == 1 && endsWith.find(tok->str()[0]) != std::string::npos) ? tok : nullptr;
23642364
}
23652365
return nullptr;
23662366
}

0 commit comments

Comments
 (0)