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 To: devel@lists.altlinux.org References: <20191213003225.71e5de1963ffea37fcd4c140@altlinux.org> <20191213091845.104792-1-darktemplar@altlinux.org> From: Aleksei Nikiforov Message-ID: <3fc54881-14bc-d8bb-a432-79e0f695ad7c@altlinux.org> Date: Fri, 13 Dec 2019 12:20:39 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191213091845.104792-1-darktemplar@altlinux.org> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Language: ru Content-Transfer-Encoding: 8bit Subject: Re: [devel] [PATCH for apt v4] Additional loops improvements and beautification 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 09:20:43 -0000 Archived-At: List-Archive: List-Post: This patch should be positioned after 'Fix iterators comparison' one. 13.12.2019 12:18, Aleksei Nikiforov пишет: > Reduce iterators scope. > Update loop conditions and iteration expressions. > --- > apt/cmdline/apt-get.cc | 12 +++++------- > apt/cmdline/apt-shell.cc | 2 +- > apt/methods/http.cc | 2 +- > 3 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc > index 74993e6..535df0a 100644 > --- a/apt/cmdline/apt-get.cc > +++ b/apt/cmdline/apt-get.cc > @@ -542,8 +542,7 @@ bool DownloadPackages(vector &URLLst) > pkgAcquire Fetcher(&Stat); > > // Load the requestd sources into the fetcher > - vector::const_iterator I = URLLst.begin(); > - for (; I != URLLst.end(); ++I) > + for (auto I = URLLst.begin(); I != URLLst.end(); ++I) > new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I)); > > // Run it > @@ -1722,8 +1721,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > return false; > > // Install everything with the install flag set > - pkgCache::PkgIterator I = Cache->PkgBegin(); > - for (;I.end() != true; I++) > + for (auto I = Cache->PkgBegin(); not I.end(); ++I) > { > /* Install the package only if it is a new install, the autoupgrader > will deal with the rest */ > @@ -1733,7 +1731,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > > /* Now install their deps too, if we do this above then order of > the status file is significant for | groups */ > - for (I = Cache->PkgBegin();I.end() != true; I++) > + for (auto I = Cache->PkgBegin(); not I.end(); ++I) > { > /* Install the package only if it is a new install, the autoupgrader > will deal with the rest */ > @@ -1742,7 +1740,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > } > > // Apply erasures now, they override everything else. > - for (I = Cache->PkgBegin();I.end() != true; I++) > + for (auto I = Cache->PkgBegin(); not I.end(); ++I) > { > // Remove packages > if (I->SelectedState == pkgCache::State::DeInstall || > @@ -1759,7 +1757,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > // Hold back held packages. > if (_config->FindB("APT::Ignore-Hold",false) == false) > { > - for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++) > + for (auto I = Cache->PkgBegin(); not I.end(); ++I) > { > if (I->SelectedState == pkgCache::State::Hold) > { > diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc > index b9ae00d..3a6748b 100644 > --- a/apt/cmdline/apt-shell.cc > +++ b/apt/cmdline/apt-shell.cc > @@ -3050,7 +3050,7 @@ bool DoList(CommandLine &CmdL) > if (Pkg->CurrentVer != 0) > { > status = "installed"; > - for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++) > + for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D) > { > pkgCache::PkgIterator P = D.ParentPkg(); > if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential && > diff --git a/apt/methods/http.cc b/apt/methods/http.cc > index 75b6873..c9a37de 100644 > --- a/apt/methods/http.cc > +++ b/apt/methods/http.cc > @@ -386,7 +386,7 @@ int ServerState::RunHeaders() > if (Debug == true) > clog << Data; > > - for (string::const_iterator I = Data.begin(); I < Data.end(); ++I) > + for (string::const_iterator I = Data.begin(); I != Data.end(); ++I) > { > string::const_iterator J = I; > for (; J != Data.end() && *J != '\n' && *J != '\r';++J); >