This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list
- 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 19:12:40 -0000
- Subject: [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This is picked up from http://gcc.gnu.org/ml/gcc/2007-07/msg00681.html ,
apologises if it has already been dealt with.
Both std::string and std::list do not compare lengths before comparing elements
in operator==. In std::string this increases the chances of quitting early and
produces a small improvement even for equal length strings. For std::list this
produces a much larger gain. I believe the operator== for list should simply be
replaced implementation used for all the other containers:
{ return (__x.size() == __y.size()
&& std::equal(__x.begin(), __x.end(), __y.begin())); }
Which is efficent as list has a O(1) size.
--
Summary: Inefficent operator== in std::string and std::list
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
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=32907