diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -874,6 +874,7 @@ _LIBCPP_INLINE_VISIBILITY operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } + // Optimization opportunity: do not externally instantiate basic_string& operator=(const basic_string& __str); template ::value, void>::type> @@ -2266,7 +2267,10 @@ if (this != &__str) { __copy_assign_alloc(__str); - return assign(__str.data(), __str.size()); + if (__is_long() | __str.__is_long()) { // LINT: explicit binary or. + return assign(__str.data(), __str.size()); + } + __r_.first().__r = __str.__r_.first().__r; } return *this; }