public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list
@ 2007-07-26 19:12 chris at bubblescope dot net
2007-07-26 19:35 ` [Bug libstdc++/32907] " pcarlini at suse dot de
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: chris at bubblescope dot net @ 2007-07-26 19:12 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/32907] Inefficent operator== in std::string and std::list
2007-07-26 19:12 [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list chris at bubblescope dot net
@ 2007-07-26 19:35 ` pcarlini at suse dot de
2007-07-26 19:41 ` chris at bubblescope dot net
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-07-26 19:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pcarlini at suse dot de 2007-07-26 19:35 -------
Well, in our current, C++03, implementation, definitely list::size is O(N). The
issue is thorny, as you know well. For C++0x, Howard has a proposal related to
the additional splice overload, I'm not sure which is the progress on that...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32907
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/32907] Inefficent operator== in std::string and std::list
2007-07-26 19:12 [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list chris at bubblescope dot net
2007-07-26 19:35 ` [Bug libstdc++/32907] " pcarlini at suse dot de
@ 2007-07-26 19:41 ` chris at bubblescope dot net
2007-07-26 21:51 ` [Bug libstdc++/32907] Inefficient operator== in std::string pcarlini at suse dot de
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: chris at bubblescope dot net @ 2007-07-26 19:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from chris at bubblescope dot net 2007-07-26 19:41 -------
Ah, woops, many apologises. Too long since I've looked at list::size, I forgot
which way around libstdc++ differed from the rest of the world :)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32907
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/32907] Inefficient operator== in std::string
2007-07-26 19:12 [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list chris at bubblescope dot net
2007-07-26 19:35 ` [Bug libstdc++/32907] " pcarlini at suse dot de
2007-07-26 19:41 ` chris at bubblescope dot net
@ 2007-07-26 21:51 ` pcarlini at suse dot de
2007-07-27 17:25 ` paolo at gcc dot gnu dot org
2007-07-27 17:26 ` pcarlini at suse dot de
4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-07-26 21:51 UTC (permalink / raw)
To: gcc-bugs
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-07-26 21:51:02
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32907
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/32907] Inefficient operator== in std::string
2007-07-26 19:12 [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list chris at bubblescope dot net
` (2 preceding siblings ...)
2007-07-26 21:51 ` [Bug libstdc++/32907] Inefficient operator== in std::string pcarlini at suse dot de
@ 2007-07-27 17:25 ` paolo at gcc dot gnu dot org
2007-07-27 17:26 ` pcarlini at suse dot de
4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-07-27 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from paolo at gcc dot gnu dot org 2007-07-27 17:25 -------
Subject: Bug 32907
Author: paolo
Date: Fri Jul 27 17:25:04 2007
New Revision: 126988
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126988
Log:
2007-07-27 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/32907
* include/bits/basic_string.h (operator==(const basic_string<_CharT>&,
const basic_string<_CharT>&)): Add.
(operator!=): Forward to operator==.
* include/ext/vstring.h(operator==(const __versa_string<_CharT,
std::char_traits<_CharT>, std::allocator<_CharT>, _Base>&,
const __versa_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT>, _Base>&)): Add.
(operator!=): Forward to operator==.
* include/ext/sso_string_base.h (_M_compare): Remove.
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/basic_string.h
trunk/libstdc++-v3/include/ext/sso_string_base.h
trunk/libstdc++-v3/include/ext/vstring.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32907
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/32907] Inefficient operator== in std::string
2007-07-26 19:12 [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list chris at bubblescope dot net
` (3 preceding siblings ...)
2007-07-27 17:25 ` paolo at gcc dot gnu dot org
@ 2007-07-27 17:26 ` pcarlini at suse dot de
4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-07-27 17:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pcarlini at suse dot de 2007-07-27 17:25 -------
Fixed for 4.3.0.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32907
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-07-27 17:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 19:12 [Bug libstdc++/32907] New: Inefficent operator== in std::string and std::list chris at bubblescope dot net
2007-07-26 19:35 ` [Bug libstdc++/32907] " pcarlini at suse dot de
2007-07-26 19:41 ` chris at bubblescope dot net
2007-07-26 21:51 ` [Bug libstdc++/32907] Inefficient operator== in std::string pcarlini at suse dot de
2007-07-27 17:25 ` paolo at gcc dot gnu dot org
2007-07-27 17:26 ` pcarlini at suse dot de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).