Refactoring; do not use pointless lambda

This commit is contained in:
Daniel Marjamäki 2020-09-03 18:58:25 +02:00
parent 5acd6fcdc8
commit efa113db55
1 changed files with 7 additions and 10 deletions

View File

@ -1409,17 +1409,14 @@ void CheckOther::checkConstVariable()
} }
// Skip if we ever cast this variable to a pointer/reference to a non-const type // Skip if we ever cast this variable to a pointer/reference to a non-const type
{ {
bool castToNonConst = [&] { bool castToNonConst = false;
for (const Token* tok = var->nameToken(); tok != scope->bodyEnd && tok != nullptr; tok = tok->next()) for (const Token* tok = var->nameToken(); tok != scope->bodyEnd && tok != nullptr; tok = tok->next()) {
{
if (tok->isCast()) { if (tok->isCast()) {
bool isConst = 0 != (tok->valueType()->constness & (1 << tok->valueType()->pointer)); bool isConst = 0 != (tok->valueType()->constness & (1 << tok->valueType()->pointer));
if (!isConst) if (!isConst)
return true; castToNonConst = true;
} }
} }
return false;
}();
if (castToNonConst) if (castToNonConst)
continue; continue;
} }