Skip to content

Commit 4fde950

Browse files
committed
small Tokenizer::isFunctionHead() optimization
1 parent 5ed2d3b commit 4fde950

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/tokenlist.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,11 +2258,11 @@ const Token * TokenList::isFunctionHead(const Token *tok, const std::string &end
22582258
if (Token::Match(tok, ") ;|{|[")) {
22592259
tok = tok->next();
22602260
while (tok && tok->str() == "[" && tok->link()) {
2261-
if (endsWith.find(tok->str()) != std::string::npos)
2261+
if (endsWith.find('[') != std::string::npos)
22622262
return tok;
22632263
tok = tok->link()->next();
22642264
}
2265-
return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
2265+
return (tok && tok->str().length() == 1 && endsWith.find(tok->str()[0]) != std::string::npos) ? tok : nullptr;
22662266
}
22672267
if (tok->isCpp() && tok->str() == ")") {
22682268
tok = tok->next();
@@ -2297,7 +2297,7 @@ const Token * TokenList::isFunctionHead(const Token *tok, const std::string &end
22972297
}
22982298
if (tok && tok->str() == ":" && !Token::Match(tok->next(), "%name%|::"))
22992299
return nullptr;
2300-
return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
2300+
return (tok && tok->str().length() == 1 && endsWith.find(tok->str()[0]) != std::string::npos) ? tok : nullptr;
23012301
}
23022302
return nullptr;
23032303
}

0 commit comments

Comments
 (0)