]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "libstdc++: Optimize operator+(string/char*, char*/string) equally"
authorJonathan Wakely <jwakely@redhat.com>
Wed, 24 Aug 2022 22:47:43 +0000 (23:47 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 24 Aug 2022 22:47:43 +0000 (23:47 +0100)
This reverts commit 0b7c9254998b3fb2c39f6b86b5b196f415530205.

libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc

index fa6738925bb1732094d409c7fb6dee67624ee2c8..b04fba956783fdcea83deaab763b6744787583c5 100644 (file)
@@ -3521,9 +3521,14 @@ _GLIBCXX_END_NAMESPACE_CXX11
    */
   template<typename _CharT, typename _Traits, typename _Alloc>
     _GLIBCXX20_CONSTEXPR
-    basic_string<_CharT, _Traits, _Alloc>
+    inline basic_string<_CharT, _Traits, _Alloc>
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
-             const _CharT* __rhs);
+             const _CharT* __rhs)
+    {
+      basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
+      __str.append(__rhs);
+      return __str;
+    }
 
   /**
    *  @brief  Concatenate string and character.
index 95ba8e503e9b38a43257fbb553ef9ec80e373d90..4563c61429a6b35f8431c728f9eb37357faefbd1 100644 (file)
@@ -640,27 +640,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __str;
     }
 
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    _GLIBCXX20_CONSTEXPR
-    basic_string<_CharT, _Traits, _Alloc>
-    operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
-             const _CharT* __rhs)
-    {
-      __glibcxx_requires_string(__rhs);
-      typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
-      typedef typename __string_type::size_type          __size_type;
-      typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
-       rebind<_CharT>::other _Char_alloc_type;
-      typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits;
-      const __size_type __len = _Traits::length(__rhs);
-      __string_type __str(_Alloc_traits::_S_select_on_copy(
-          __lhs.get_allocator()));
-      __str.reserve(__len + __lhs.size());
-      __str.append(__lhs);
-      __str.append(__rhs, __len);
-      return __str;
-    }
-
   template<typename _CharT, typename _Traits, typename _Alloc>
     _GLIBCXX_STRING_CONSTEXPR
     typename basic_string<_CharT, _Traits, _Alloc>::size_type