[libcxx-commits] [libcxx] 52f37c2 - [libc++][NFC] remove this-> when calling member functions in <string>
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 24 15:23:37 PST 2022
Author: Nikolas Klauser
Date: 2022-01-25T00:21:51+01:00
New Revision: 52f37c24c3f891350394c30096be5e93b063f61e
URL: https://github.com/llvm/llvm-project/commit/52f37c24c3f891350394c30096be5e93b063f61e
DIFF: https://github.com/llvm/llvm-project/commit/52f37c24c3f891350394c30096be5e93b063f61e.diff
LOG: [libc++][NFC] remove this-> when calling member functions in <string>
remove `this->` when calling member functions
Reviewed By: Quuxplusone, Mordante, ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D116324
Added:
Modified:
libcxx/include/string
Removed:
################################################################################
diff --git a/libcxx/include/string b/libcxx/include/string
index 6f22f02afa0ba..f53e1bfef75e8 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1866,7 +1866,7 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
size_type __reserve)
{
if (__reserve > max_size())
- this->__throw_length_error();
+ __throw_length_error();
pointer __p;
if (__fits_in_sso(__reserve))
{
@@ -1890,7 +1890,7 @@ void
basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
{
if (__sz > max_size())
- this->__throw_length_error();
+ __throw_length_error();
pointer __p;
if (__fits_in_sso(__sz))
{
@@ -1973,7 +1973,7 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
__set_short_size(__sz);
} else {
if (__sz > max_size())
- this->__throw_length_error();
+ __throw_length_error();
size_t __cap = __recommend(__sz);
__p = __alloc_traits::allocate(__alloc(), __cap + 1);
__set_long_pointer(__p);
@@ -2029,7 +2029,7 @@ void
basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
{
if (__n > max_size())
- this->__throw_length_error();
+ __throw_length_error();
pointer __p;
if (__fits_in_sso(__n))
{
@@ -2074,7 +2074,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
{
size_type __str_sz = __str.size();
if (__pos > __str_sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
__init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));
_VSTD::__debug_db_insert_c(this);
}
@@ -2087,7 +2087,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
{
size_type __str_sz = __str.size();
if (__pos > __str_sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
__init(__str.data() + __pos, __str_sz - __pos);
_VSTD::__debug_db_insert_c(this);
}
@@ -2160,7 +2160,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
{
size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__sz > max_size())
- this->__throw_length_error();
+ __throw_length_error();
pointer __p;
if (__fits_in_sso(__sz))
{
@@ -2259,7 +2259,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
{
size_type __ms = max_size();
if (__delta_cap > __ms - __old_cap - 1)
- this->__throw_length_error();
+ __throw_length_error();
pointer __old_p = __get_pointer();
size_type __cap = __old_cap < __ms / 2 - __alignment ?
__recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
@@ -2291,7 +2291,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
{
size_type __ms = max_size();
if (__delta_cap > __ms - __old_cap)
- this->__throw_length_error();
+ __throw_length_error();
pointer __old_p = __get_pointer();
size_type __cap = __old_cap < __ms / 2 - __alignment ?
__recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
@@ -2523,7 +2523,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz
{
size_type __sz = __str.size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
}
@@ -2540,7 +2540,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p
__self_view __sv = __t;
size_type __sz = __sv.size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
}
@@ -2709,7 +2709,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz
{
size_type __sz = __str.size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
}
@@ -2725,7 +2725,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p
__self_view __sv = __t;
size_type __sz = __sv.size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
}
@@ -2746,7 +2746,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr");
size_type __sz = size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
size_type __cap = capacity();
if (__cap - __sz >= __n)
{
@@ -2777,7 +2777,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
{
size_type __sz = size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
if (__n)
{
size_type __cap = capacity();
@@ -2883,7 +2883,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
{
size_type __str_sz = __str.size();
if (__pos2 > __str_sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
}
@@ -2900,7 +2900,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _
__self_view __sv = __t;
size_type __str_sz = __sv.size();
if (__pos2 > __str_sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
}
@@ -2961,7 +2961,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
size_type __sz = size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
__n1 = _VSTD::min(__n1, __sz - __pos);
size_type __cap = capacity();
if (__cap - __sz + __n1 >= __n2)
@@ -3008,7 +3008,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
{
size_type __sz = size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
__n1 = _VSTD::min(__n1, __sz - __pos);
size_type __cap = capacity();
value_type* __p;
@@ -3042,7 +3042,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
_InputIterator __j1, _InputIterator __j2)
{
const basic_string __temp(__j1, __j2, __alloc());
- return this->replace(__i1, __i2, __temp);
+ return replace(__i1, __i2, __temp);
}
template <class _CharT, class _Traits, class _Allocator>
@@ -3060,7 +3060,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
{
size_type __str_sz = __str.size();
if (__pos2 > __str_sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
}
@@ -3077,7 +3077,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
__self_view __sv = __t;
size_type __str_sz = __sv.size();
if (__pos2 > __str_sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
}
@@ -3147,7 +3147,8 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
size_type __n) {
- if (__pos > size()) this->__throw_out_of_range();
+ if (__pos > size())
+ __throw_out_of_range();
if (__n == npos) {
__erase_to_end(__pos);
} else {
@@ -3263,7 +3264,7 @@ void
basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
{
if (__requested_capacity > max_size())
- this->__throw_length_error();
+ __throw_length_error();
// Make sure reserve(n) never shrinks. This is technically only required in C++20
// and later (since P0966R1), however we provide consistent behavior in all Standard
@@ -3370,7 +3371,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::const_reference
basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
{
if (__n >= size())
- this->__throw_out_of_range();
+ __throw_out_of_range();
return (*this)[__n];
}
@@ -3379,7 +3380,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::reference
basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
{
if (__n >= size())
- this->__throw_out_of_range();
+ __throw_out_of_range();
return (*this)[__n];
}
@@ -3425,7 +3426,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,
{
size_type __sz = size();
if (__pos > __sz)
- this->__throw_out_of_range();
+ __throw_out_of_range();
size_type __rlen = _VSTD::min(__n, __sz - __pos);
traits_type::copy(__s, data() + __pos, __rlen);
return __rlen;
@@ -3869,7 +3870,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
size_type __sz = size();
if (__pos1 > __sz || __n2 == npos)
- this->__throw_out_of_range();
+ __throw_out_of_range();
size_type __rlen = _VSTD::min(__n1, __sz - __pos1);
int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2));
if (__r == 0)
@@ -3933,7 +3934,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __pos2,
size_type __n2) const
{
- return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);
+ return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);
}
template <class _CharT, class _Traits, class _Allocator>
@@ -4447,16 +4448,16 @@ template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
{
- return this->data() <= _VSTD::__to_address(__i->base()) &&
- _VSTD::__to_address(__i->base()) < this->data() + this->size();
+ return data() <= _VSTD::__to_address(__i->base()) &&
+ _VSTD::__to_address(__i->base()) < data() + size();
}
template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
{
- return this->data() < _VSTD::__to_address(__i->base()) &&
- _VSTD::__to_address(__i->base()) <= this->data() + this->size();
+ return data() < _VSTD::__to_address(__i->base()) &&
+ _VSTD::__to_address(__i->base()) <= data() + size();
}
template<class _CharT, class _Traits, class _Allocator>
@@ -4464,7 +4465,7 @@ bool
basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptr
diff _t __n) const
{
const value_type* __p = _VSTD::__to_address(__i->base()) + __n;
- return this->data() <= __p && __p <= this->data() + this->size();
+ return data() <= __p && __p <= data() + size();
}
template<class _CharT, class _Traits, class _Allocator>
@@ -4472,7 +4473,7 @@ bool
basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptr
diff _t __n) const
{
const value_type* __p = _VSTD::__to_address(__i->base()) + __n;
- return this->data() <= __p && __p < this->data() + this->size();
+ return data() <= __p && __p < data() + size();
}
#endif // _LIBCPP_DEBUG_LEVEL == 2
More information about the libcxx-commits
mailing list