early break in loop for readability

This commit is contained in:
Dmitry-Me 2015-02-13 16:36:20 +01:00 committed by Daniel Marjamäki
parent 7961bba0da
commit 5674b3c49d
1 changed files with 6 additions and 3 deletions

View File

@ -643,13 +643,16 @@ void CheckOther::checkRedundantAssignment()
for (const Token* tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) {
if (tok2->str() == ";")
break;
else if (tok2->varId() == tok->varId())
else if (tok2->varId() == tok->varId()) {
error = false;
else if (Token::Match(tok2, "%name% (") && nonLocal(tok->variable())) { // Called function might use the variable
break;
} else if (Token::Match(tok2, "%name% (") && nonLocal(tok->variable())) { // Called function might use the variable
const Function* const func = tok2->function();
const Variable* const var = tok->variable();
if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) // Global variable, or member function
if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) {// Global variable, or member function
error = false;
break;
}
}
}
if (error) {