diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2017-11-17 00:51:20 +0100 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2017-11-16 23:51:20 +0000 |
commit | c261ba2c8b4244128528f964192ca4f4edf1eef5 (patch) | |
tree | 1b4cc99a3d7117b0c5547e6c1ed8ca8382d586e8 /libstdc++-v3 | |
parent | b1e35f49e89151ac2b4263e151a2a65d3b45a479 (diff) | |
download | gcc-c261ba2c8b4244128528f964192ca4f4edf1eef5.zip gcc-c261ba2c8b4244128528f964192ca4f4edf1eef5.tar.gz gcc-c261ba2c8b4244128528f964192ca4f4edf1eef5.tar.bz2 |
Tweak vector::_M_realloc_insert for code size
2017-11-17 Marc Glisse <marc.glisse@inria.fr>
* include/bits/vector.tcc (vector::_M_realloc_insert): Cache old
values before the allocation.
From-SVN: r254849
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/vector.tcc | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4fe0be1..3c9f3e7 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2017-11-17 Marc Glisse <marc.glisse@inria.fr> + + * include/bits/vector.tcc (vector::_M_realloc_insert): Cache old + values before the allocation. + 2017-11-16 Jonathan Wakely <jwakely@redhat.com> * include/std/future (shared_future): Add noexcept to copy constructor diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index f14caaa..eadce3c 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -421,6 +421,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { const size_type __len = _M_check_len(size_type(1), "vector::_M_realloc_insert"); + pointer __old_start = this->_M_impl._M_start; + pointer __old_finish = this->_M_impl._M_finish; const size_type __elems_before = __position - begin(); pointer __new_start(this->_M_allocate(__len)); pointer __new_finish(__new_start); @@ -442,14 +444,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __new_finish = std::__uninitialized_move_if_noexcept_a - (this->_M_impl._M_start, __position.base(), + (__old_start, __position.base(), __new_start, _M_get_Tp_allocator()); ++__new_finish; __new_finish = std::__uninitialized_move_if_noexcept_a - (__position.base(), this->_M_impl._M_finish, + (__position.base(), __old_finish, __new_finish, _M_get_Tp_allocator()); } __catch(...) @@ -463,10 +465,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __throw_exception_again; } _GLIBCXX_ASAN_ANNOTATE_REINIT; - std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, - _M_get_Tp_allocator()); - _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); + std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator()); + _M_deallocate(__old_start, + this->_M_impl._M_end_of_storage - __old_start); this->_M_impl._M_start = __new_start; this->_M_impl._M_finish = __new_finish; this->_M_impl._M_end_of_storage = __new_start + __len; |