[libcxx-commits] [libcxx] [libc++][NFC] Simplify the implementation of reserve() and shrink_to_fit() (PR #113453)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 23 06:03:36 PDT 2024
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 ac5a2010ad35a72de3e75a1883e2495345b92a73 cf86ee2c74422961a1b7f59ed6789cd7b63f6f09 --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 55b174f4db..8805a0ea05 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2061,7 +2061,7 @@ private:
// Disable ASan annotations and enable them again when going out of scope. It is assumed that the string is in a valid
// state at that point, so `size()` can be called safely.
struct [[__nodiscard__]] __annotation_guard {
- __annotation_guard(const __annotation_guard&) = delete;
+ __annotation_guard(const __annotation_guard&) = delete;
__annotation_guard& operator=(const __annotation_guard&) = delete;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __annotation_guard(basic_string& __str) : __str_(__str) {
@@ -3355,7 +3355,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
__annotation_guard __g(*this);
auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);
- auto __size = size();
+ auto __size = size();
__begin_lifetime(__allocation.ptr, __allocation.count);
traits_type::copy(std::__to_address(__allocation.ptr), data(), __size + 1);
if (__is_long())
@@ -3375,9 +3375,9 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
if (!__is_long())
return;
__annotation_guard __g(*this);
- auto __ptr = __get_long_pointer();
+ auto __ptr = __get_long_pointer();
auto __size = __get_long_size();
- auto __cap = __get_long_cap();
+ auto __cap = __get_long_cap();
traits_type::copy(std::__to_address(__get_short_pointer()), data(), __size + 1);
__alloc_traits::deallocate(__alloc_, __ptr, __cap);
__set_short_size(__size);
@@ -3391,7 +3391,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
try {
#endif // _LIBCPP_HAS_EXCEPTIONS
__annotation_guard __g(*this);
- auto __size = size();
+ auto __size = size();
auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);
// The Standard mandates shrink_to_fit() does not increase the capacity.
``````````
</details>
https://github.com/llvm/llvm-project/pull/113453
More information about the libcxx-commits
mailing list