This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::string::reserve()
Neil Ferguson wrote:
Shrink-to-fit became significant for me when I discovered that users
of libstdc++ here at ESO were reading large blocks of data from files
into strings, without knowing how big the blocks were until reaching
the end of said blocks.
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... 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.
Just le me know: I can quickly prepare a patch and your users can test
it for a while.
Paolo.