From 2582bbd0f6bb43232a97051cdc4aab55c828e3bb Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 24 Aug 2017 18:10:33 +0300 Subject: [PATCH] Break loop early --- lib/checkunusedvar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index f5d331589..5530cea10 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -979,8 +979,10 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const { const Token *parent = tok->astParent(); while (parent) { - if (Token::simpleMatch(parent->previous(), "while (")) + if (Token::simpleMatch(parent->previous(), "while (")) { inwhile = true; + break; + } parent = parent->astParent(); } }