Skip to content

Commit e187fdb

Browse files
committed
tokenlist::iscast(): save a few pointer dereferences.
1 parent 7163210 commit e187fdb

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/tokenlist.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,11 @@ static bool iscast(const Token *tok)
391391
if (!Token::Match(tok, "( ::| %name%"))
392392
return false;
393393

394-
if (tok->previous() && tok->previous()->isName() && tok->previous()->str() != "return")
394+
const Token *prevTok = tok->previous();
395+
if (prevTok && prevTok->isName() && prevTok->str() != "return")
395396
return false;
396397

397-
if (Token::simpleMatch(tok->previous(), ">") && tok->previous()->link())
398+
if (Token::simpleMatch(prevTok, ">") && prevTok->link())
398399
return false;
399400

400401
if (Token::Match(tok, "( (| typeof (") && Token::Match(tok->link(), ") %num%"))
@@ -406,7 +407,7 @@ static bool iscast(const Token *tok)
406407
if (Token::Match(tok->link(), ") %cop%") && !Token::Match(tok->link(), ") [&*+-~]"))
407408
return false;
408409

409-
if (Token::Match(tok->previous(), "= ( %name% ) {") && tok->next()->varId() == 0)
410+
if (Token::Match(prevTok, "= ( %name% ) {") && tok->next()->varId() == 0)
410411
return true;
411412

412413
bool type = false;

0 commit comments

Comments
 (0)