From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 From: Aleksei Nikiforov To: devel@lists.altlinux.org Date: Fri, 13 Dec 2019 11:23:19 +0300 Message-Id: <20191213082319.102365-1-darktemplar@altlinux.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191212225553.e467fee203adc96d3a6060e0@altlinux.org> References: <20191212225553.e467fee203adc96d3a6060e0@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Aleksei Nikiforov Subject: [devel] [PATCH for apt v3] DoList: optimize status modification loop X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Dec 2019 08:23:28 -0000 Archived-At: List-Archive: List-Post: If value is assigned once, there's no need to keep iterating since until the end of loop value would not be changed anymore. Found while working on previous issue discovered using cppcheck. --- apt/cmdline/apt-shell.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc index 26811c4..951bc3c 100644 --- a/apt/cmdline/apt-shell.cc +++ b/apt/cmdline/apt-shell.cc @@ -3054,6 +3054,7 @@ bool DoList(CommandLine &CmdL) (P->Flags & pkgCache::Flag::Important) != pkgCache::Flag::Important) continue; status = "locked"; + break; } } if (Pkg->CurrentVer != 0 && Cache[Pkg].Upgradable() == true) status = "upgradable"; -- 2.24.1