[libcxx-commits] [libcxx] [libc++] Optimize basic_string::operator= (PR #224535)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 28 01:17:10 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) {
----------------
philnik777 wrote:

I actually wanted to use this function for `assign(const value_type*)` as well, so I don't think we want to take a `const basic_string&`. I've added an internal assert though that `strlen(__s) == __n` and updated the documentation.

https://github.com/llvm/llvm-project/pull/224535


More information about the libcxx-commits mailing list