Reorder checks to avoid redundant actions

This commit is contained in:
Dmitry-Me 2014-11-30 16:14:53 +03:00
parent 6482fefe3e
commit c0d2933ec7
1 changed files with 4 additions and 2 deletions

View File

@ -445,10 +445,12 @@ void CheckOther::invalidPointerCast()
nextTok = nextTok->next();
toTok = tok->tokAt(2);
}
if (!nextTok)
continue;
if (toTok && toTok->str() == "const")
toTok = toTok->next();
if (!nextTok || !toTok || !toTok->isStandardType())
if (!toTok || !toTok->isStandardType())
continue;
// Find casted variable
@ -649,7 +651,7 @@ void CheckOther::checkRedundantAssignment()
}
}
if (error) {
if (scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok) && warning)
if (warning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
redundantAssignmentInSwitchError(it->second, tok, tok->str());
else if (performance) {
const bool nonlocal = nonLocal(it->second->variable());