public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-2192] Revert "libstdc++: Optimize operator+(string/char*, char*/string) equally"
Date: Wed, 24 Aug 2022 22:51:49 +0000 (GMT)	[thread overview]
Message-ID: <20220824225149.44A02385841A@sourceware.org> (raw)

https://gcc.gnu.org/g:e5428086c2c8daf69e5916dd5016d1e7b85d3f0d

commit r13-2192-ge5428086c2c8daf69e5916dd5016d1e7b85d3f0d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 24 23:47:43 2022 +0100

    Revert "libstdc++: Optimize operator+(string/char*, char*/string) equally"
    
    This reverts commit 0b7c9254998b3fb2c39f6b86b5b196f415530205.

Diff:
---
 libstdc++-v3/include/bits/basic_string.h   |  9 +++++++--
 libstdc++-v3/include/bits/basic_string.tcc | 21 ---------------------
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index fa6738925bb..b04fba95678 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -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.
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 95ba8e503e9..4563c61429a 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -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

                 reply	other threads:[~2022-08-24 22:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220824225149.44A02385841A@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).