[libcxx-commits] [libcxx] [libc++][NFC] Simplify string a bit (PR #127135)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 16 01:52:46 PST 2025
================
@@ -3477,11 +3461,13 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT {
- size_type __old_size = size();
+ size_type __old_size;
if (__is_long()) {
+ __old_size = __get_long_size();
traits_type::assign(*__get_long_pointer(), value_type());
__set_long_size(0);
} else {
+ __old_size = __get_short_size();
----------------
philnik777 wrote:
I'm not convinced this is an improvement. The compiler should be perfectly able to fold this and splitting the call makes it in comparison much harder to verify correctness.
https://github.com/llvm/llvm-project/pull/127135
More information about the libcxx-commits
mailing list