Skip to content

Commit ce96a5e

Browse files
committed
Run cheaper checks first
1 parent 4c843eb commit ce96a5e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/checkcondition.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ void CheckCondition::oppositeInnerCondition()
400400
nonlocal |= (var && (!var->isLocal() || var->isStatic()) && !var->isArgument());
401401
// TODO: if var is pointer check what it points at
402402
nonlocal |= (var && (var->isPointer() || var->isReference()));
403-
} else if (cond->isName()) {
403+
} else if (!nonlocal && cond->isName()) {
404404
// varid is 0. this is possibly a nonlocal variable..
405-
nonlocal |= Token::Match(cond->astParent(), "%cop%|(");
405+
nonlocal = Token::Match(cond->astParent(), "%cop%|(");
406406
}
407407
}
408408

@@ -429,8 +429,8 @@ void CheckCondition::oppositeInnerCondition()
429429
if (Token::Match(tok->previous(), "++|--|& %name%"))
430430
break;
431431
if (tok->variable() &&
432-
Token::Match(tok, "%name% . %name% (") &&
433-
!tok->variable()->isConst()) {
432+
!tok->variable()->isConst() &&
433+
Token::Match(tok, "%name% . %name% (")) {
434434
const Function* function = tok->tokAt(2)->function();
435435
if (!function || !function->isConst())
436436
break;

0 commit comments

Comments
 (0)