From f4ddf43cbac7f796f047c252ce574266bc48c127 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Wed, 20 Dec 2017 03:55:43 +0300 Subject: [PATCH] Break loop early, simplify check --- lib/checkother.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index f7bd81b22..19ed54d6e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -526,12 +526,10 @@ void CheckOther::checkRedundantAssignment() bool bailout = false; for (const Token *tok3 = tok2->link(); tok3 != tok2; tok3 = tok3->previous()) { if (tok3->varId()) { - if (!tok3->variable()) + const Variable *var = tok3->variable(); + if (!var || !var->isConst() || var->isReference() || var->isPointer()) { bailout = true; - else { - const Variable *var = tok3->variable(); - if (!var->isConst() || var->isReference() || var->isPointer()) - bailout = true; + break; } } }