Skip to content

Commit 5c2cbf9

Browse files
committed
Unify naming of internal pointer members in std::vector and std::__split_buffer
1 parent bde3d4a commit 5c2cbf9

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

libcxx/include/__split_buffer

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ _LIBCPP_PUSH_MACROS
4747
_LIBCPP_BEGIN_NAMESPACE_STD
4848

4949
// __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).
50-
// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __end_cap_.first()). That allows
50+
// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __cap_). That allows
5151
// it to grow both in the front and back without having to move the data.
5252

5353
template <class _Tp, class _Allocator = allocator<_Tp> >
@@ -78,20 +78,20 @@ public:
7878
pointer __first_;
7979
pointer __begin_;
8080
pointer __end_;
81-
_LIBCPP_COMPRESSED_PAIR(pointer, __end_cap_, allocator_type, __alloc_);
81+
_LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);
8282

8383
__split_buffer(const __split_buffer&) = delete;
8484
__split_buffer& operator=(const __split_buffer&) = delete;
8585

8686
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()
8787
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
88-
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) {}
88+
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) {}
8989

9090
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a)
91-
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr), __alloc_(__a) {}
91+
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}
9292

9393
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a)
94-
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr), __alloc_(__a) {}
94+
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}
9595

9696
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
9797
__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
@@ -123,15 +123,15 @@ public:
123123
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; }
124124

125125
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {
126-
return static_cast<size_type>(__end_cap_ - __first_);
126+
return static_cast<size_type>(__cap_ - __first_);
127127
}
128128

129129
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {
130130
return static_cast<size_type>(__begin_ - __first_);
131131
}
132132

133133
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {
134-
return static_cast<size_type>(__end_cap_ - __end_);
134+
return static_cast<size_type>(__cap_ - __end_);
135135
}
136136

137137
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; }
@@ -219,14 +219,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants
219219
return false;
220220
if (__end_ != nullptr)
221221
return false;
222-
if (__end_cap_ != nullptr)
222+
if (__cap_ != nullptr)
223223
return false;
224224
} else {
225225
if (__begin_ < __first_)
226226
return false;
227227
if (__end_ < __begin_)
228228
return false;
229-
if (__end_cap_ < __end_)
229+
if (__cap_ < __end_)
230230
return false;
231231
}
232232
return true;
@@ -273,8 +273,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
273273
__split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) {
274274
__alloc_rr& __a = __alloc_;
275275
for (; __first != __last; ++__first) {
276-
if (__end_ == __end_cap_) {
277-
size_type __old_cap = __end_cap_ - __first_;
276+
if (__end_ == __cap_) {
277+
size_type __old_cap = __cap_ - __first_;
278278
size_type __new_cap = std::max<size_type>(2 * __old_cap, 8);
279279
__split_buffer __buf(__new_cap, 0, __a);
280280
for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)
@@ -331,7 +331,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
331331
template <class _Tp, class _Allocator>
332332
_LIBCPP_CONSTEXPR_SINCE_CXX20
333333
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
334-
: __end_cap_(nullptr), __alloc_(__a) {
334+
: __cap_(nullptr), __alloc_(__a) {
335335
if (__cap == 0) {
336336
__first_ = nullptr;
337337
} else {
@@ -340,7 +340,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
340340
__cap = __allocation.count;
341341
}
342342
__begin_ = __end_ = __first_ + __start;
343-
__end_cap_ = __first_ + __cap;
343+
__cap_ = __first_ + __cap;
344344
}
345345

346346
template <class _Tp, class _Allocator>
@@ -356,32 +356,32 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__
356356
: __first_(std::move(__c.__first_)),
357357
__begin_(std::move(__c.__begin_)),
358358
__end_(std::move(__c.__end_)),
359-
__end_cap_(std::move(__c.__end_cap_)),
359+
__cap_(std::move(__c.__cap_)),
360360
__alloc_(std::move(__c.__alloc_)) {
361361
__c.__first_ = nullptr;
362362
__c.__begin_ = nullptr;
363363
__c.__end_ = nullptr;
364-
__c.__end_cap_ = nullptr;
364+
__c.__cap_ = nullptr;
365365
}
366366

367367
template <class _Tp, class _Allocator>
368368
_LIBCPP_CONSTEXPR_SINCE_CXX20
369369
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
370-
: __end_cap_(nullptr), __alloc_(__a) {
370+
: __cap_(nullptr), __alloc_(__a) {
371371
if (__a == __c.__alloc_) {
372372
__first_ = __c.__first_;
373373
__begin_ = __c.__begin_;
374374
__end_ = __c.__end_;
375-
__end_cap_ = __c.__end_cap_;
375+
__cap_ = __c.__cap_;
376376
__c.__first_ = nullptr;
377377
__c.__begin_ = nullptr;
378378
__c.__end_ = nullptr;
379-
__c.__end_cap_ = nullptr;
379+
__c.__cap_ = nullptr;
380380
} else {
381381
auto __allocation = std::__allocate_at_least(__alloc_, __c.size());
382382
__first_ = __allocation.ptr;
383383
__begin_ = __end_ = __first_;
384-
__end_cap_ = __first_ + __allocation.count;
384+
__cap_ = __first_ + __allocation.count;
385385
typedef move_iterator<iterator> _Ip;
386386
__construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
387387
}
@@ -398,9 +398,9 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
398398
__first_ = __c.__first_;
399399
__begin_ = __c.__begin_;
400400
__end_ = __c.__end_;
401-
__end_cap_ = __c.__end_cap_;
401+
__cap_ = __c.__cap_;
402402
__move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
403-
__c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap_ = nullptr;
403+
__c.__first_ = __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;
404404
return *this;
405405
}
406406

@@ -410,7 +410,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split
410410
std::swap(__first_, __x.__first_);
411411
std::swap(__begin_, __x.__begin_);
412412
std::swap(__end_, __x.__end_);
413-
std::swap(__end_cap_, __x.__end_cap_);
413+
std::swap(__cap_, __x.__cap_);
414414
std::__swap_allocator(__alloc_, __x.__alloc_);
415415
}
416416

@@ -422,7 +422,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::reserve(size
422422
std::swap(__first_, __t.__first_);
423423
std::swap(__begin_, __t.__begin_);
424424
std::swap(__end_, __t.__end_);
425-
std::swap(__end_cap_, __t.__end_cap_);
425+
std::swap(__cap_, __t.__cap_);
426426
}
427427
}
428428

@@ -438,7 +438,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi
438438
std::swap(__first_, __t.__first_);
439439
std::swap(__begin_, __t.__begin_);
440440
std::swap(__end_, __t.__end_);
441-
std::swap(__end_cap_, __t.__end_cap_);
441+
std::swap(__cap_, __t.__cap_);
442442
#if _LIBCPP_HAS_EXCEPTIONS
443443
} catch (...) {
444444
}
@@ -450,19 +450,19 @@ template <class _Tp, class _Allocator>
450450
template <class... _Args>
451451
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) {
452452
if (__begin_ == __first_) {
453-
if (__end_ < __end_cap_) {
454-
difference_type __d = __end_cap_ - __end_;
453+
if (__end_ < __cap_) {
454+
difference_type __d = __cap_ - __end_;
455455
__d = (__d + 1) / 2;
456456
__begin_ = std::move_backward(__begin_, __end_, __end_ + __d);
457457
__end_ += __d;
458458
} else {
459-
size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap_ - __first_), 1);
459+
size_type __c = std::max<size_type>(2 * static_cast<size_t>(__cap_ - __first_), 1);
460460
__split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc_);
461461
__t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
462462
std::swap(__first_, __t.__first_);
463463
std::swap(__begin_, __t.__begin_);
464464
std::swap(__end_, __t.__end_);
465-
std::swap(__end_cap_, __t.__end_cap_);
465+
std::swap(__cap_, __t.__cap_);
466466
}
467467
}
468468
__alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), std::forward<_Args>(__args)...);
@@ -472,20 +472,20 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_fron
472472
template <class _Tp, class _Allocator>
473473
template <class... _Args>
474474
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
475-
if (__end_ == __end_cap_) {
475+
if (__end_ == __cap_) {
476476
if (__begin_ > __first_) {
477477
difference_type __d = __begin_ - __first_;
478478
__d = (__d + 1) / 2;
479479
__end_ = std::move(__begin_, __end_, __begin_ - __d);
480480
__begin_ -= __d;
481481
} else {
482-
size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap_ - __first_), 1);
482+
size_type __c = std::max<size_type>(2 * static_cast<size_t>(__cap_ - __first_), 1);
483483
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc_);
484484
__t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
485485
std::swap(__first_, __t.__first_);
486486
std::swap(__begin_, __t.__begin_);
487487
std::swap(__end_, __t.__end_);
488-
std::swap(__end_cap_, __t.__end_cap_);
488+
std::swap(__cap_, __t.__cap_);
489489
}
490490
}
491491
__alloc_traits::construct(__alloc_, std::__to_address(__end_), std::forward<_Args>(__args)...);

libcxx/include/__vector/vector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
822822
__end_ = __begin_; // All the objects have been destroyed by relocating them.
823823
std::swap(this->__begin_, __v.__begin_);
824824
std::swap(this->__end_, __v.__end_);
825-
std::swap(this->__end_cap(), __v.__end_cap_);
825+
std::swap(this->__end_cap(), __v.__cap_);
826826
__v.__first_ = __v.__begin_;
827827
__annotate_new(size());
828828
}
@@ -852,7 +852,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
852852

853853
std::swap(this->__begin_, __v.__begin_);
854854
std::swap(this->__end_, __v.__end_);
855-
std::swap(this->__end_cap(), __v.__end_cap_);
855+
std::swap(this->__end_cap(), __v.__cap_);
856856
__v.__first_ = __v.__begin_;
857857
__annotate_new(size());
858858
return __ret;

libcxx/include/deque

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity() {
20732073
std::swap(__map_.__first_, __buf.__first_);
20742074
std::swap(__map_.__begin_, __buf.__begin_);
20752075
std::swap(__map_.__end_, __buf.__end_);
2076-
std::swap(__map_.__end_cap_, __buf.__end_cap_);
2076+
std::swap(__map_.__cap_, __buf.__cap_);
20772077
__start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size;
20782078
}
20792079
__annotate_whole_block(0, __asan_poison);
@@ -2150,7 +2150,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
21502150
std::swap(__map_.__first_, __buf.__first_);
21512151
std::swap(__map_.__begin_, __buf.__begin_);
21522152
std::swap(__map_.__end_, __buf.__end_);
2153-
std::swap(__map_.__end_cap_, __buf.__end_cap_);
2153+
std::swap(__map_.__cap_, __buf.__cap_);
21542154
__start_ += __ds;
21552155
}
21562156
}
@@ -2196,7 +2196,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity() {
21962196
std::swap(__map_.__first_, __buf.__first_);
21972197
std::swap(__map_.__begin_, __buf.__begin_);
21982198
std::swap(__map_.__end_, __buf.__end_);
2199-
std::swap(__map_.__end_cap_, __buf.__end_cap_);
2199+
std::swap(__map_.__cap_, __buf.__cap_);
22002200
__annotate_whole_block(__map_.size() - 1, __asan_poison);
22012201
}
22022202
}
@@ -2275,7 +2275,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
22752275
std::swap(__map_.__first_, __buf.__first_);
22762276
std::swap(__map_.__begin_, __buf.__begin_);
22772277
std::swap(__map_.__end_, __buf.__end_);
2278-
std::swap(__map_.__end_cap_, __buf.__end_cap_);
2278+
std::swap(__map_.__cap_, __buf.__cap_);
22792279
__start_ -= __ds;
22802280
}
22812281
}

0 commit comments

Comments
 (0)