[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:48:58 PST 2025
================
@@ -2820,17 +2817,10 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {
- pointer __p;
size_type __old_size = size();
if (__old_size == 0)
__annotate_increase(1);
- if (__is_long()) {
- __p = __get_long_pointer();
- __set_long_size(1);
- } else {
- __p = __get_short_pointer();
- __set_short_size(1);
- }
+ pointer __p = __is_long() ? (__set_long_size(1), __get_long_pointer()) : (__set_short_size(1), __get_short_pointer());
----------------
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