This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::string::reserve()
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Neil Ferguson <nferguso at eso dot org>
- Cc: LibStdC++ General List <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 11 Feb 2004 23:23:38 +0100
- Subject: Re: std::string::reserve()
- References: <402A9983.50600@eso.org>
Neil Ferguson wrote:
I've attached diffs against latest CVS that try to avoid doing
this, and I'd be interested to know what you think.
Hi Neil, thanks for your message. A few observations:
1- If you plan contributing patches of this size you definitely need a
copyright assignment on file:
http://gcc.gnu.org/contribute.html
2- Your change definitely makes sense but not calling _M_clone has
a not-completely-obvious effect: if the string is in the leaked
state it remains leaked, doesn't become sharable. Perhaps you
want to return early only if the string is already sharable?
A leaked string cannot be refcopied and avoiding the _M_clone
call could imply having to call it *many* times later in an
assign, in a constructor or what else...
3- Please, please strive to have a working regtesting setup. It's
important not only to spare us the task (that's not a big deal)
but also when fixing bugs or envisaging large scale changes...
Paolo.