[libcxx-commits] [libcxx] [libc++] Optimize basic_string::operator= (PR #224535)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 24 06:23:56 PDT 2026
================
@@ -2727,28 +2727,40 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace(
template <class _CharT, class _Traits, class _Allocator>
template <bool __is_short>
-_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void
basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) {
----------------
ldionne wrote:
Suggestion: pass a `string const&` instead to make it clear that `__s` and `__n` are just the string's data and the size of the string.
Otherwise, we could rename `size_type __n` to `size_type __size` and document that `__size == strlen(__s)` -- basically this is just a way for the caller to pass already known information down.
https://github.com/llvm/llvm-project/pull/224535
More information about the libcxx-commits
mailing list