[devel] [PATCH for apt v3] DoList: optimize status modification loop

Aleksei Nikiforov darktemplar на altlinux.org
Пт Дек 13 11:23:19 MSK 2019


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



Подробная информация о списке рассылки Devel