Omit unneeded computations

This commit is contained in:
Dmitry-Me 2017-12-26 02:07:24 +03:00
parent eaadfb3910
commit 5a642ac35e
1 changed files with 1 additions and 1 deletions

View File

@ -180,9 +180,9 @@ bool CheckCondition::assignIfParseScope(const Token * const assignTok,
} }
if (Token::Match(tok2,"&&|%oror%|( %varid% ==|!= %num% &&|%oror%|)", varid)) { if (Token::Match(tok2,"&&|%oror%|( %varid% ==|!= %num% &&|%oror%|)", varid)) {
const Token *vartok = tok2->next(); const Token *vartok = tok2->next();
const std::string& op(vartok->strAt(1));
const MathLib::bigint num2 = MathLib::toLongNumber(vartok->strAt(2)); const MathLib::bigint num2 = MathLib::toLongNumber(vartok->strAt(2));
if ((num & num2) != ((bitop=='&') ? num2 : num)) { if ((num & num2) != ((bitop=='&') ? num2 : num)) {
const std::string& op(vartok->strAt(1));
const bool alwaysTrue = op == "!="; const bool alwaysTrue = op == "!=";
const std::string condition(vartok->str() + op + vartok->strAt(2)); const std::string condition(vartok->str() + op + vartok->strAt(2));
assignIfError(assignTok, tok2, condition, alwaysTrue); assignIfError(assignTok, tok2, condition, alwaysTrue);