[libcxx-commits] [libcxx] [libc++][NFC] Simplify the implementation of reserve() and shrink_to_fit() (PR #113453)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 23 11:00:20 PDT 2024
================
@@ -3349,70 +3371,48 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
if (__target_capacity == capacity())
return;
- __shrink_or_extend(__target_capacity);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
-basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) {
- __annotate_delete();
- size_type __cap = capacity();
- size_type __sz = size();
-
- pointer __new_data, __p;
- bool __was_long, __now_long;
if (__fits_in_sso(__target_capacity)) {
----------------
ldionne wrote:
```suggestion
// We're a long string and we're downsizing into the small buffer.
if (__fits_in_sso(__target_capacity)) {
```
https://github.com/llvm/llvm-project/pull/113453
More information about the libcxx-commits
mailing list