[libcxx-commits] [libcxx] [libc++][NFC] Simplify string a bit (PR #127135)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 20 08:49:14 PST 2025
================
@@ -3089,18 +3080,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu
}
if (__sz == __cap) {
__grow_by_without_replace(__cap, 1, __sz, __sz, 0);
- __annotate_increase(1);
__is_short = false; // the string is always long after __grow_by
- } else
- __annotate_increase(1);
- pointer __p = __get_pointer();
- if (__is_short) {
- __p = __get_short_pointer() + __sz;
- __set_short_size(__sz + 1);
- } else {
- __p = __get_long_pointer() + __sz;
- __set_long_size(__sz + 1);
}
+ __annotate_increase(1);
+ pointer __p = __is_short ? (__set_short_size(__sz + 1), __get_short_pointer() + __sz)
+ : (__set_long_size(__sz + 1), __get_long_pointer() + __sz);
----------------
winner245 wrote:
Thanks for the feedback. I’ve reverted it back to an `if/else` statement for better readability.
https://github.com/llvm/llvm-project/pull/127135
More information about the libcxx-commits
mailing list