[libcxx-commits] [libcxx] Improve string allocation (PR #92652)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 23 12:14:16 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions  -- libcxx/include/string
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/string b/libcxx/include/string
index 25ee09c6b..e861096db 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -3418,7 +3418,8 @@ _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 = size();
-  __target_capacity = __target_capacity < __min_cap ? static_cast<size_type>(__min_cap) - 1 : __recommend(__target_capacity);
+  __target_capacity =
+      __target_capacity < __min_cap ? static_cast<size_type>(__min_cap) - 1 : __recommend(__target_capacity);
   if (__target_capacity == capacity())
     return;
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/92652


More information about the libcxx-commits mailing list