From 5674b3c49de2bd0627db0bf16eab22f012d22066 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 13 Feb 2015 16:36:20 +0100 Subject: [PATCH] early break in loop for readability --- lib/checkother.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 047a546dc..124eedc50 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -643,13 +643,16 @@ void CheckOther::checkRedundantAssignment() for (const Token* tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) { if (tok2->str() == ";") break; - else if (tok2->varId() == tok->varId()) + else if (tok2->varId() == tok->varId()) { error = false; - else if (Token::Match(tok2, "%name% (") && nonLocal(tok->variable())) { // Called function might use the variable + break; + } else if (Token::Match(tok2, "%name% (") && nonLocal(tok->variable())) { // Called function might use the variable const Function* const func = tok2->function(); const Variable* const var = tok->variable(); - if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) // Global variable, or member function + if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) {// Global variable, or member function error = false; + break; + } } } if (error) {