Skip to content

Commit c248816

Browse files
committed
Replace all usages of __split_buffer::push_{back,front} by emplace_{back,front}
1 parent bdc7f81 commit c248816

File tree

3 files changed

+28
-53
lines changed

3 files changed

+28
-53
lines changed

libcxx/include/__split_buffer

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ public:
147147

148148
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
149149
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
150-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x);
151-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
152-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
153-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
154150

155151
template <class... _Args>
156152
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
@@ -456,16 +452,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi
456452
}
457453
}
458454

459-
template <class _Tp, class _Allocator>
460-
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) {
461-
emplace_front(__x);
462-
}
463-
464-
template <class _Tp, class _Allocator>
465-
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) {
466-
emplace_front(std::move(__x));
467-
}
468-
469455
template <class _Tp, class _Allocator>
470456
template <class... _Args>
471457
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) {
@@ -489,17 +475,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_fron
489475
--__begin_;
490476
}
491477

492-
template <class _Tp, class _Allocator>
493-
_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
494-
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x) {
495-
emplace_back(__x);
496-
}
497-
498-
template <class _Tp, class _Allocator>
499-
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) {
500-
emplace_back(std::move(__x));
501-
}
502-
503478
template <class _Tp, class _Allocator>
504479
template <class... _Args>
505480
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) {

libcxx/include/__vector/vector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
12631263
} else {
12641264
allocator_type& __a = this->__alloc();
12651265
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1266-
__v.push_back(__x);
1266+
__v.emplace_back(__x);
12671267
__p = __swap_out_circular_buffer(__v, __p);
12681268
}
12691269
return __make_iter(__p);
@@ -1283,7 +1283,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
12831283
} else {
12841284
allocator_type& __a = this->__alloc();
12851285
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1286-
__v.push_back(std::move(__x));
1286+
__v.emplace_back(std::move(__x));
12871287
__p = __swap_out_circular_buffer(__v, __p);
12881288
}
12891289
return __make_iter(__p);

libcxx/include/deque

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,20 +2041,20 @@ void deque<_Tp, _Allocator>::__add_front_capacity() {
20412041
__start_ += __block_size;
20422042
pointer __pt = __map_.back();
20432043
__map_.pop_back();
2044-
__map_.push_front(__pt);
2044+
__map_.emplace_front(__pt);
20452045
}
20462046
// Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer
20472047
else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around
20482048
// until all buffers are allocated. If we throw, we don't need to fix
20492049
// anything up (any added buffers are undetectible)
20502050
if (__map_.__front_spare() > 0)
2051-
__map_.push_front(__alloc_traits::allocate(__a, __block_size));
2051+
__map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
20522052
else {
2053-
__map_.push_back(__alloc_traits::allocate(__a, __block_size));
2053+
__map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
20542054
// Done allocating, reorder capacity
20552055
pointer __pt = __map_.back();
20562056
__map_.pop_back();
2057-
__map_.push_front(__pt);
2057+
__map_.emplace_front(__pt);
20582058
}
20592059
__start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size;
20602060
}
@@ -2065,11 +2065,11 @@ void deque<_Tp, _Allocator>::__add_front_capacity() {
20652065

20662066
typedef __allocator_destructor<_Allocator> _Dp;
20672067
unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size));
2068-
__buf.push_back(__hold.get());
2068+
__buf.emplace_back(__hold.get());
20692069
__hold.release();
20702070

20712071
for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i)
2072-
__buf.push_back(*__i);
2072+
__buf.emplace_back(*__i);
20732073
std::swap(__map_.__first_, __buf.__first_);
20742074
std::swap(__map_.__begin_, __buf.__begin_);
20752075
std::swap(__map_.__end_, __buf.__end_);
@@ -2095,7 +2095,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
20952095
for (; __back_capacity > 0; --__back_capacity) {
20962096
pointer __pt = __map_.back();
20972097
__map_.pop_back();
2098-
__map_.push_front(__pt);
2098+
__map_.emplace_front(__pt);
20992099
}
21002100
}
21012101
// Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
@@ -2106,17 +2106,17 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
21062106
for (; __nb > 0; --__nb, __start_ += __block_size - (__map_.size() == 1)) {
21072107
if (__map_.__front_spare() == 0)
21082108
break;
2109-
__map_.push_front(__alloc_traits::allocate(__a, __block_size));
2109+
__map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
21102110
__annotate_whole_block(0, __asan_poison);
21112111
}
21122112
for (; __nb > 0; --__nb, ++__back_capacity)
2113-
__map_.push_back(__alloc_traits::allocate(__a, __block_size));
2113+
__map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
21142114
// Done allocating, reorder capacity
21152115
__start_ += __back_capacity * __block_size;
21162116
for (; __back_capacity > 0; --__back_capacity) {
21172117
pointer __pt = __map_.back();
21182118
__map_.pop_back();
2119-
__map_.push_front(__pt);
2119+
__map_.emplace_front(__pt);
21202120
__annotate_whole_block(0, __asan_poison);
21212121
}
21222122
}
@@ -2129,7 +2129,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
21292129
try {
21302130
#endif // _LIBCPP_HAS_EXCEPTIONS
21312131
for (; __nb > 0; --__nb) {
2132-
__buf.push_back(__alloc_traits::allocate(__a, __block_size));
2132+
__buf.emplace_back(__alloc_traits::allocate(__a, __block_size));
21332133
// ASan: this is empty container, we have to poison whole block
21342134
__annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size));
21352135
}
@@ -2142,11 +2142,11 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
21422142
}
21432143
#endif // _LIBCPP_HAS_EXCEPTIONS
21442144
for (; __back_capacity > 0; --__back_capacity) {
2145-
__buf.push_back(__map_.back());
2145+
__buf.emplace_back(__map_.back());
21462146
__map_.pop_back();
21472147
}
21482148
for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i)
2149-
__buf.push_back(*__i);
2149+
__buf.emplace_back(*__i);
21502150
std::swap(__map_.__first_, __buf.__first_);
21512151
std::swap(__map_.__begin_, __buf.__begin_);
21522152
std::swap(__map_.__end_, __buf.__end_);
@@ -2164,20 +2164,20 @@ void deque<_Tp, _Allocator>::__add_back_capacity() {
21642164
__start_ -= __block_size;
21652165
pointer __pt = __map_.front();
21662166
__map_.pop_front();
2167-
__map_.push_back(__pt);
2167+
__map_.emplace_back(__pt);
21682168
}
21692169
// Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
21702170
else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around
21712171
// until it is allocated. If we throw, we don't need to fix
21722172
// anything up (any added buffers are undetectible)
21732173
if (__map_.__back_spare() != 0)
2174-
__map_.push_back(__alloc_traits::allocate(__a, __block_size));
2174+
__map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
21752175
else {
2176-
__map_.push_front(__alloc_traits::allocate(__a, __block_size));
2176+
__map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
21772177
// Done allocating, reorder capacity
21782178
pointer __pt = __map_.front();
21792179
__map_.pop_front();
2180-
__map_.push_back(__pt);
2180+
__map_.emplace_back(__pt);
21812181
}
21822182
__annotate_whole_block(__map_.size() - 1, __asan_poison);
21832183
}
@@ -2188,11 +2188,11 @@ void deque<_Tp, _Allocator>::__add_back_capacity() {
21882188

21892189
typedef __allocator_destructor<_Allocator> _Dp;
21902190
unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size));
2191-
__buf.push_back(__hold.get());
2191+
__buf.emplace_back(__hold.get());
21922192
__hold.release();
21932193

21942194
for (__map_pointer __i = __map_.end(); __i != __map_.begin();)
2195-
__buf.push_front(*--__i);
2195+
__buf.emplace_front(*--__i);
21962196
std::swap(__map_.__first_, __buf.__first_);
21972197
std::swap(__map_.__begin_, __buf.__begin_);
21982198
std::swap(__map_.__end_, __buf.__end_);
@@ -2217,7 +2217,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
22172217
for (; __front_capacity > 0; --__front_capacity) {
22182218
pointer __pt = __map_.front();
22192219
__map_.pop_front();
2220-
__map_.push_back(__pt);
2220+
__map_.emplace_back(__pt);
22212221
}
22222222
}
22232223
// Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
@@ -2228,19 +2228,19 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
22282228
for (; __nb > 0; --__nb) {
22292229
if (__map_.__back_spare() == 0)
22302230
break;
2231-
__map_.push_back(__alloc_traits::allocate(__a, __block_size));
2231+
__map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
22322232
__annotate_whole_block(__map_.size() - 1, __asan_poison);
22332233
}
22342234
for (; __nb > 0; --__nb, ++__front_capacity, __start_ += __block_size - (__map_.size() == 1)) {
2235-
__map_.push_front(__alloc_traits::allocate(__a, __block_size));
2235+
__map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
22362236
__annotate_whole_block(0, __asan_poison);
22372237
}
22382238
// Done allocating, reorder capacity
22392239
__start_ -= __block_size * __front_capacity;
22402240
for (; __front_capacity > 0; --__front_capacity) {
22412241
pointer __pt = __map_.front();
22422242
__map_.pop_front();
2243-
__map_.push_back(__pt);
2243+
__map_.emplace_back(__pt);
22442244
}
22452245
}
22462246
// Else need to allocate __nb buffers, *and* we need to reallocate __map_.
@@ -2254,7 +2254,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
22542254
try {
22552255
#endif // _LIBCPP_HAS_EXCEPTIONS
22562256
for (; __nb > 0; --__nb) {
2257-
__buf.push_back(__alloc_traits::allocate(__a, __block_size));
2257+
__buf.emplace_back(__alloc_traits::allocate(__a, __block_size));
22582258
// ASan: this is an empty container, we have to poison the whole block
22592259
__annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size));
22602260
}
@@ -2267,11 +2267,11 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
22672267
}
22682268
#endif // _LIBCPP_HAS_EXCEPTIONS
22692269
for (; __front_capacity > 0; --__front_capacity) {
2270-
__buf.push_back(__map_.front());
2270+
__buf.emplace_back(__map_.front());
22712271
__map_.pop_front();
22722272
}
22732273
for (__map_pointer __i = __map_.end(); __i != __map_.begin();)
2274-
__buf.push_front(*--__i);
2274+
__buf.emplace_front(*--__i);
22752275
std::swap(__map_.__first_, __buf.__first_);
22762276
std::swap(__map_.__begin_, __buf.__begin_);
22772277
std::swap(__map_.__end_, __buf.__end_);

0 commit comments

Comments
 (0)