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(); nextTok = nextTok->next();
toTok = tok->tokAt(2); toTok = tok->tokAt(2);
} }
if (!nextTok)
continue;
if (toTok && toTok->str() == "const") if (toTok && toTok->str() == "const")
toTok = toTok->next(); toTok = toTok->next();
if (!nextTok || !toTok || !toTok->isStandardType()) if (!toTok || !toTok->isStandardType())
continue; continue;
// Find casted variable // Find casted variable
@ -649,7 +651,7 @@ void CheckOther::checkRedundantAssignment()
} }
} }
if (error) { 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()); redundantAssignmentInSwitchError(it->second, tok, tok->str());
else if (performance) { else if (performance) {
const bool nonlocal = nonLocal(it->second->variable()); const bool nonlocal = nonLocal(it->second->variable());