std::list optimizations

François Dumont frs.dumont@gmail.com
Fri Jul 28 16:43:00 GMT 2017


Hi

     Completing execution of the testsuite revealed a bug. So here is 
the correct version of this patch.

François

On 21/07/2017 19:14, François Dumont wrote:
> Hi
>
>     Here is a proposal for 2 optimizations in the std::list 
> implementation.
>
>     Optimization on the move constructor taking an allocator for 
> always equal allocators. Compare to the version in my previous 
> std::list patch I am now doing it at std::list level rather than at 
> _List_base level. This way we won't instantiate the insert call and we 
> won't check for empty list when the allocator always compare equal.
>
>     2nd optimization, I replace the _S_distance method by the 
> std::distance algo which benefit from the nice [begin(), end()) range 
> optimization when cxx11 abi is being used.
>
>     Note that I am proposing the 2 change in 1 patch to save some 
> review time but I can commit those separately.
>
> Tested under x86_64 Linux normal mode.
>
>
>     * include/bits/stl_list.h
>     (_List_base<>::_S_distance): Remove.
>     (_List_impl(_List_impl&&, _Node_alloc_type&&)): New.
>     (_List_base(_List_base&&, _Node_alloc_type&&)): Use latter.
>     (_List_base(_Node_alloc_type&&)): New.
>     (_List_base<>::_M_distance, _List_base<>::_M_node_count): Move...
>     (list<>::_M_distance, list<>::_M_node_count): ...here. Replace 
> calls to
>     _S_distance with calls to std::distance.
>     (list(list&&, const allocator_type&, true_type)): New.
>     (list(list&&, const allocator_type&, false_type)): New.
>     (list(list&&, const allocator_type&)): Adapt to call latters.
>
> Ok to commit ?
>
> François
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: list.patch
Type: text/x-patch
Size: 5300 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170728/6f7c03b6/attachment.bin>


More information about the Libstdc++ mailing list