From 696c5b8100472e1ec20bb18e23f75a56f6b83b0d Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 18 Sep 2017 03:06:35 +0300 Subject: [PATCH] Reduce duplication, omit building unneeded string --- lib/checkcondition.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index fd09fcca3..f1e1f2fad 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -182,11 +182,11 @@ bool CheckCondition::assignIfParseScope(const Token * const assignTok, const Token *vartok = tok2->next(); const std::string& op(vartok->strAt(1)); const MathLib::bigint num2 = MathLib::toLongNumber(vartok->strAt(2)); - const std::string condition(vartok->str() + op + vartok->strAt(2)); - if (op == "==" && (num & num2) != ((bitop=='&') ? num2 : num)) - assignIfError(assignTok, tok2, condition, false); - else if (op == "!=" && (num & num2) != ((bitop=='&') ? num2 : num)) - assignIfError(assignTok, tok2, condition, true); + if ((num & num2) != ((bitop=='&') ? num2 : num)) { + const bool alwaysTrue = op == "!="; + const std::string condition(vartok->str() + op + vartok->strAt(2)); + assignIfError(assignTok, tok2, condition, alwaysTrue); + } } if (Token::Match(tok2, "%varid% %op%", varid) && tok2->next()->isAssignmentOp()) { return true;