Merge pull request #412 from Dmitry-Me/moveChecksEarlier
Move cheap checks earlier to avoid more expensive ones
This commit is contained in:
commit
9bc0e3afd6
|
@ -87,15 +87,15 @@ bool CheckCondition::assignIfParseScope(const Token * const assignTok,
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
for (const Token *tok2 = startTok; tok2; tok2 = tok2->next()) {
|
for (const Token *tok2 = startTok; tok2; tok2 = tok2->next()) {
|
||||||
if (Token::Match(tok2->tokAt(2), "%varid% %cop% %num% ;", varid) && tok2->strAt(3) == std::string(1U, bitop)) {
|
if ((bitop == '&') && Token::Match(tok2->tokAt(2), "%varid% %cop% %num% ;", varid) && tok2->strAt(3) == std::string(1U, bitop)) {
|
||||||
const MathLib::bigint num2 = MathLib::toLongNumber(tok2->strAt(4));
|
const MathLib::bigint num2 = MathLib::toLongNumber(tok2->strAt(4));
|
||||||
if ((bitop == '&') && (0 == (num & num2)))
|
if (0 == (num & num2))
|
||||||
mismatchingBitAndError(assignTok, num, tok2, num2);
|
mismatchingBitAndError(assignTok, num, tok2, num2);
|
||||||
}
|
}
|
||||||
if (Token::Match(tok2, "%varid% =", varid)) {
|
if (Token::Match(tok2, "%varid% =", varid)) {
|
||||||
if (Token::Match(tok2->tokAt(2), "%varid% %cop% %num% ;", varid) && tok2->strAt(3) == std::string(1U, bitop)) {
|
if ((bitop == '&') && Token::Match(tok2->tokAt(2), "%varid% %cop% %num% ;", varid) && tok2->strAt(3) == std::string(1U, bitop)) {
|
||||||
const MathLib::bigint num2 = MathLib::toLongNumber(tok2->strAt(4));
|
const MathLib::bigint num2 = MathLib::toLongNumber(tok2->strAt(4));
|
||||||
if ((bitop == '&') && (0 == (num & num2)))
|
if (0 == (num & num2))
|
||||||
mismatchingBitAndError(assignTok, num, tok2, num2);
|
mismatchingBitAndError(assignTok, num, tok2, num2);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue