std::string::reserve()

Neil Ferguson nferguso@eso.org
Wed Nov 24 19:21:00 GMT 2004


I've submitted bugzilla report 18654 for this:

   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18654

Paolo Carlini wrote:
 >
> Humm, what about exact-shrink-to-fit *always*? I mean, not attempting at 
> all to round to pagesize when the user code calls reserve(< capacity)? 
> If, in your experience, this looks fine, we can implement it easily, 
> changing only _S_create in a very clean way. And of course your original 
> concern would "magically" ;) disappear... 

I like this idea - it feels a lot cleaner than my original one, and it 
should certainly solve the issue at hand.

> In my opinion, the idea makes 
> sense, since, in those specific situations when the user really asks for 
> shrink-to-fit, doing our best to achieve it is more important than 
> rounding to pagesize and trying to be smart wrt malloc requests.

Agreed. I have the annoying feeling of not having seen the wood for the 
trees now :)

> Just le me know: I can quickly prepare a patch and your users can test 
> it for a while.
> 
> Paolo.

I would be delighted to test a patch against my own work; I have a test
suite that happens to exercise the string functionality we use quite a 
bit. Unfortunately, I won't be able to get the users to try it, because 
(among other things) we have a general rule that we never use code that 
didn't come from an "official release". Would that be acceptable?

Neil.



More information about the Libstdc++ mailing list