Reduce duplication, omit building unneeded string

This commit is contained in:
Dmitry-Me 2017-09-18 03:06:35 +03:00
parent 7d6ef71c4d
commit 696c5b8100
1 changed files with 5 additions and 5 deletions

View File

@ -182,11 +182,11 @@ bool CheckCondition::assignIfParseScope(const Token * const assignTok,
const Token *vartok = tok2->next(); const Token *vartok = tok2->next();
const std::string& op(vartok->strAt(1)); 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));
const std::string condition(vartok->str() + op + vartok->strAt(2)); if ((num & num2) != ((bitop=='&') ? num2 : num)) {
if (op == "==" && (num & num2) != ((bitop=='&') ? num2 : num)) const bool alwaysTrue = op == "!=";
assignIfError(assignTok, tok2, condition, false); const std::string condition(vartok->str() + op + vartok->strAt(2));
else if (op == "!=" && (num & num2) != ((bitop=='&') ? num2 : num)) assignIfError(assignTok, tok2, condition, alwaysTrue);
assignIfError(assignTok, tok2, condition, true); }
} }
if (Token::Match(tok2, "%varid% %op%", varid) && tok2->next()->isAssignmentOp()) { if (Token::Match(tok2, "%varid% %op%", varid) && tok2->next()->isAssignmentOp()) {
return true; return true;