debug shrink_to_fit
François Dumont
francois.cppdevs@free.fr
Tue Jun 14 20:33:00 GMT 2011
On 06/14/2011 10:03 PM, Jonathan Wakely wrote:
> On 14 June 2011 20:40, François Dumont wrote:
>> Thanks for having taken care of it and sorry for having misunderstood your
>> proposition, I was indeed surprised to be free to change shrink_to_fit
>> signature, I know why now.
>>
>> I have however some remarks:
>>
>> 1. Attached you will find a small patch that fix a mistake from the original
>> patch that was missing state full allocator management:
>>
>> 2011-06-14 François Dumont<francois.cppdevs@free.fr>
>>
>> * include/bits/allocator.h (__shrink_to_fit_aux::_S_do_it): Pass
>> source instance allocator to destination.
>>
>> Ok to apply ?
> Does it pass the testsuite? (please always state so in patch submissions)
>
> It's not quite as simple as that, I'm not sure whether it should use
> allocator_traits::select_on_container_copy_construction() there
> instead, and a stateful allocator may not be exchanged by the swap,
> potentially copying all the elements twice, making shrink_to_fit very
> slow!
>
Yes, it passes shrink_to_fit tests on linux x86_64.
I will read more about this select_on_container_copy_constructor I do
not know so far.
Regards
More information about the Libstdc++
mailing list