std::vector<bool> code cleanup fixes optimizations
François Dumont
frs.dumont@gmail.com
Mon Jun 24 19:31:00 GMT 2019
Hi
   Any feedback regarding this patch ?
Thanks
On 5/14/19 7:46 AM, François Dumont wrote:
> Hi
>
> Â Â Â This is the patch on vector<bool> to:
>
> - Optimize sizeof in Versioned namespace mode. We could go one step
> further by removing _M_p from _M_finish and just transform it into an
> offset but it is a little bit more impacting for the code.
>
> - Implement the swap optimization already done on main std::vector
> template class.
>
> - Fix move constructor so that it is noexcept no matter allocator move
> constructor noexcept qualification
>
> - Optimize move constructor with allocator when allocator type is
> always equal.
>
> - Use shortcuts in C++11 by skipping the _M_XXX_dispatch methods.
> Those are now defined only in pre-C++11 mode, I can't see any abi
> issue in doing so.
>
> Â Â Â * include/bits/stl_bvector.h
> Â Â Â [_GLIBCXX_INLINE_VERSION](_Bvector_impl_data::_M_start): Define as
> Â Â Â _Bit_type*.
> Â Â Â (_Bvector_impl_data(const _Bvector_impl_data&)): Default.
> Â Â Â (_Bvector_impl_data(_Bvector_impl_data&&)): Delegate to latter.
> Â Â Â (_Bvector_impl_data::operator=(const _Bvector_impl_data&)): Default.
> (_Bvector_impl_data::_M_move_data(_Bvector_impl_data&&)): Use latter.
> Â Â Â (_Bvector_impl_data::_M_reset()): Likewise.
> Â Â Â (_Bvector_impl_data::_M_swap_data): New.
> Â Â Â (_Bvector_impl::_Bvector_impl(_Bvector_impl&&)): Implement
> explicitely.
> Â Â Â (_Bvector_impl::_Bvector_impl(_Bit_alloc_type&&,
> _Bvector_impl&&)): New.
> Â Â Â (_Bvector_base::_Bvector_base(_Bvector_base&&, const
> allocator_type&)):
> Â Â Â New, use latter.
> Â Â Â (vector::vector(vector&&, const allocator_type&, true_type)): New,
> use
> Â Â Â latter.
> Â Â Â (vector::vector(vector&&, const allocator_type&, false_type)): New.
> Â Â Â (vector::vector(vector&&, const allocator_type&)): Use latters.
> Â Â Â (vector::vector(const vector&, const allocator_type&)): Adapt.
> Â Â Â [__cplusplus >= 201103](vector::vector(_InputIt, _InputIt,
> Â Â Â const allocator_type&)): Use _M_initialize_range.
> Â Â Â (vector::operator[](size_type)): Use iterator operator[].
> Â Â Â (vector::operator[](size_type) const): Use const_iterator operator[].
> Â Â Â (vector::swap(vector&)): Adapt.
> Â Â Â (vector::_M_initialize(size_type)): Add assertions on allocators.
> Â Â Â Use _M_swap_data.
> Â Â Â [__cplusplus >= 201103](vector::insert(const_iterator, _InputIt,
> Â Â Â _InputIt)): Use _M_insert_range.
> Â Â Â [__cplusplus >= 201103](vector::_M_initialize_dispatch): Remove.
> Â Â Â [__cplusplus >= 201103](vector::_M_insert_dispatch): Remove.
> Â Â Â * testsuite/23_containers/vector/bool/allocator/swap.cc: Adapt.
> Â Â Â *
> testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc:
> Â Â Â Add check.
>
> Tested under Linux x86_64, normal and debug modes.
>
> Ok to commit ?
>
> François
>
More information about the Libstdc++
mailing list