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 Date: Fri, 13 Dec 2019 00:32:25 +0300 From: Andrey Savchenko To: ALT Linux Team development discussions Message-Id: <20191213003225.71e5de1963ffea37fcd4c140@altlinux.org> In-Reply-To: <20191212095730.83787-2-darktemplar@altlinux.org> References: <20191211234857.GB17949@altlinux.org> <20191212095730.83787-1-darktemplar@altlinux.org> <20191212095730.83787-2-darktemplar@altlinux.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA512"; boundary="Signature=_Fri__13_Dec_2019_00_32_25_+0300_soF4kRHdfqbs+L5w" Subject: Re: [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments 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: Thu, 12 Dec 2019 21:32:32 -0000 Archived-At: List-Archive: List-Post: --Signature=_Fri__13_Dec_2019_00_32_25_+0300_soF4kRHdfqbs+L5w Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, 12 Dec 2019 12:57:10 +0300 Aleksei Nikiforov wrote: > Found via cppcheck: > (performance) Prefer prefix ++/-- operators for non-primitive types. [...] > diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc > index a26c93c..3858752 100644 > --- a/apt/cmdline/apt-get.cc > +++ b/apt/cmdline/apt-get.cc > @@ -541,8 +541,7 @@ bool DownloadPackages(vector &URLLst) > pkgAcquire Fetcher(&Stat); > =20 > // Load the requestd sources into the fetcher > - vector::const_iterator I =3D URLLst.begin(); > - for (; I !=3D URLLst.end(); I++) > + for (auto I =3D URLLst.begin(); I !=3D URLLst.end(); ++I) > new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I)); This one contains the unrelated change for the iterator initialization. If you really need this cosmetics, submit it as a separate patch. > @@ -551,7 +550,7 @@ bool DownloadPackages(vector &URLLst) > =20 > // Print error messages > bool Failed =3D false; > - for (pkgAcquire::ItemIterator I =3D Fetcher.ItemsBegin(); I !=3D Fetc= her.ItemsEnd(); I++) > + for (auto I =3D Fetcher.ItemsBegin(); I !=3D Fetcher.ItemsEnd(); ++I) Same here. > @@ -1721,8 +1720,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > return false; > =20 > // Install everything with the install flag set > - pkgCache::PkgIterator I =3D Cache->PkgBegin(); > - for (;I.end() !=3D true; I++) > + for (auto I =3D Cache->PkgBegin(); not I.end(); ++I) And here. > @@ -1732,7 +1730,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > =20 > /* Now install their deps too, if we do this above then order of > the status file is significant for | groups */ > - for (I =3D Cache->PkgBegin();I.end() !=3D true; I++) > + for (auto I =3D Cache->PkgBegin(); not I.end(); ++I) And here. > { > /* Install the package only if it is a new install, the autoupgrad= er > will deal with the rest */ > @@ -1741,7 +1739,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > } > =20 > // Apply erasures now, they override everything else. > - for (I =3D Cache->PkgBegin();I.end() !=3D true; I++) > + for (auto I =3D Cache->PkgBegin(); not I.end(); ++I) And here. > @@ -1758,7 +1756,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) > // Hold back held packages. > if (_config->FindB("APT::Ignore-Hold",false) =3D=3D false) > { > - for (pkgCache::PkgIterator I =3D Cache->PkgBegin(); I.end() =3D=3D fal= se; I++) > + for (auto I =3D Cache->PkgBegin(); not I.end(); ++I) And here. > diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc > index 9582291..0aa5da5 100644 > --- a/apt/cmdline/apt-shell.cc > +++ b/apt/cmdline/apt-shell.cc > @@ -3034,7 +3034,7 @@ bool DoList(CommandLine &CmdL) > string status =3D "available"; > if (Pkg->CurrentVer !=3D 0) status =3D "installed"; > if (Pkg->CurrentVer !=3D 0) > - for (pkgCache::DepIterator D =3D Pkg.RevDependsList(); D.e= nd() =3D=3D false; D++) > + for (pkgCache::DepIterator D =3D Pkg.RevDependsList(); not= D.end(); ++D) Same here. Though this D.end() related change looks as an absolutely useless cosmetics. > diff --git a/apt/methods/http.cc b/apt/methods/http.cc > index dcdd651..da3e646 100644 > --- a/apt/methods/http.cc > +++ b/apt/methods/http.cc > @@ -383,10 +383,10 @@ int ServerState::RunHeaders() > if (Debug =3D=3D true) > clog << Data; > =20 > - for (string::const_iterator I =3D Data.begin(); I < Data.end(); I+= +) > + for (string::const_iterator I =3D Data.begin(); I !=3D Data.end();= ++I) This is the correct change. But yet again it is unrelated to the patch description, please submit Data.end() fix as a separate patch. Other changes LGTM. They may improve performance (and may not depending on how smart a compiler is), but are harmless otherwise. Best regards, Andrew Savchenko --Signature=_Fri__13_Dec_2019_00_32_25_+0300_soF4kRHdfqbs+L5w Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE63ZIHsdeM+1XgNer9lNaM7oe5I0FAl3ysekACgkQ9lNaM7oe 5I2oVw/+OcZy22XjvwwI+MLqWGA7K//Z70d1E31Kmv7T32zpuloOrILMINGFAKwd GZxguETeEUgu3ecnyKs/xmKPY7p5V4HDZRzL7GF5/1caJaUMQAAL/ZM2JXOy8X93 XfWATq9C7GtPGW4SZdG7QOEBrItH80rdXNSSxQrmxTEdmbWa8hd1Hq+a8sB1cbf6 XNXHCn8ysLQwsO6g4qDYE50HfCpf4xlxSnBii+oI3tGiFbR3zkZG3Zhdr5SxKms1 7YzL+Vv46ApT5cKEy+M236hPXqVuB/B6F3w6eCcsOJTlk0WNRVtpYpvEx52eKio3 4G1fSiw3dV5VFFAv7Bclf1ZiVKQVhWWFtQe5EUZPNQkGFenN+YBJn26bMKuUkd27 k4V4Omiz6jx550m7qJW5G0MuGjuU7omNw98fRrjaEo6Ijao6HGhKKK7u1LrQ6r95 BqMjOGXb7Yx1s8iqi3SJaYlKealaIty8gDNrEx1nx2npoE5YCcXF1uOJpNYUSR+p qHuwasEzClRLQ/w1h405F/0HJEP/ptJ8R2sMT6PGsTY35X6RCAaXZe7lBzZP/oEI zO2ONTdtipgCUgIySFlyMp5G/WqtFZFIoMpojVBN9lFfZuOdZq5trpWrpw2ggJp4 iSdKUmxqpJKU5KPJFPQFusTc/SPA7rVSTX76uVW4D+GfBji+rF8= =rx83 -----END PGP SIGNATURE----- --Signature=_Fri__13_Dec_2019_00_32_25_+0300_soF4kRHdfqbs+L5w--