This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/32908] New: Miss lexicographical_compare random access override
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jul 2007 20:37:15 -0000
- Subject: [Bug libstdc++/32908] New: Miss lexicographical_compare random access override
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
lexicographical_compare is used to implement operator< and friends on all
containers. The code is not optimised for random_access iterators, where we can
find which list is the longest before starting and save one comparison every
loop.
Replace the following line:
for (; __first1 != __last1 && __first2 != __last2;
++__first1, ++__first2)
With:
_InputIterator1 __newlast1 = __first1 +
std::min(__last1 - __first1, __last2 - __first2);
for (; __first1 != __newlast1;
++__first1, ++__first2)
(or something similar.
This produces a 15% speed improve on operator< on vector<int>.
If this bug remains I will write up code myself, but I am unable to compile g++
from source at the moment.
--
Summary: Miss lexicographical_compare random access override
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chris at bubblescope dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32908