From kde-devel Sun Oct 31 18:32:10 2004 From: "Aaron J. Seigo" Date: Sun, 31 Oct 2004 18:32:10 +0000 To: kde-devel Subject: Re: "Fixed" post-increment operators on iterators Message-Id: <200410311132.10366.aseigo () kde ! org> X-MARC-Message: https://marc.info/?l=kde-devel&m=109924784127873 On Sunday 31 October 2004 05:27, Esben Mose Hansen wrote: > On Sunday 31 October, 2004 12:59, Frederik Schmid wrote: > > > QStringList::ConstIterator itEnd = matches.end(); > > > for(QStringList::ConstIterator it = matches.begin(); it != itEnd; ++it) > > > _keyList->insertItem(*it); > > [...] > > > The compiler will (almost certainly) move loop-conditions out ouf the > > loop, so no need to add extra lines in this case. > > I have always wondered about that. Unless the container is const, how can > the compiler know that mycontainer->end() always returns the same value? exactly, and so it won't, and so caching the return value of end() (or length(), or...) almost always results in a speedup (of how much and of what impact is another matter) > Also, why is it we don't use STL? The above could be written as (untested) probably a combination of the fact that STL support on all the platforms people use KDE on has traditionally sucked and that many people aren't familiar with the STL. -- Aaron J. Seigo GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43 >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<