Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -2292,14 +2292,9 @@ private:
}
enum { __alignment = 8 };
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT {
if (__s < __min_cap) {
return static_cast<size_type>(__min_cap) - 1;
}
_LIBCPP_ASSERT_INTERNAL(__s >= __min_cap, "recommend is called for small string capacity");
const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor;
size_type __guess = __align_it<__boundary>(__s + 1) - 1;
if (__guess == __min_cap)
__guess += __endian_factor;

_LIBCPP_ASSERT_INTERNAL(__guess >= __s, "recommendation is below the requested size");
return __guess;
}
Expand Down Expand Up @@ -3435,7 +3430,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re

template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT {
size_type __target_capacity = __recommend(size());
size_type __target_capacity = size();
__target_capacity =
__target_capacity < __min_cap ? static_cast<size_type>(__min_cap) - 1 : __recommend(__target_capacity);
if (__target_capacity == capacity())
return;

Expand Down