From ce96a5e84f08886b1ba5f0bacb5e4ac2ded2a048 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 7 Aug 2015 16:25:47 +0300 Subject: [PATCH] Run cheaper checks first --- lib/checkcondition.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 57cb4bfb4..814ae51d2 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -400,9 +400,9 @@ void CheckCondition::oppositeInnerCondition() nonlocal |= (var && (!var->isLocal() || var->isStatic()) && !var->isArgument()); // TODO: if var is pointer check what it points at nonlocal |= (var && (var->isPointer() || var->isReference())); - } else if (cond->isName()) { + } else if (!nonlocal && cond->isName()) { // varid is 0. this is possibly a nonlocal variable.. - nonlocal |= Token::Match(cond->astParent(), "%cop%|("); + nonlocal = Token::Match(cond->astParent(), "%cop%|("); } } @@ -429,8 +429,8 @@ void CheckCondition::oppositeInnerCondition() if (Token::Match(tok->previous(), "++|--|& %name%")) break; if (tok->variable() && - Token::Match(tok, "%name% . %name% (") && - !tok->variable()->isConst()) { + !tok->variable()->isConst() && + Token::Match(tok, "%name% . %name% (")) { const Function* function = tok->tokAt(2)->function(); if (!function || !function->isConst()) break;