Message ID | 20220822181509.1032874-2-whh8b@obs.cr |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp615312wro; Mon, 22 Aug 2022 11:17:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6YXuNFPqwxPCcDDBCth+RIdE7wnenRwbC1PjBLVAhumlGAShR5/zbUH0PqdaJVbmvjrmVF X-Received: by 2002:a17:907:6e0c:b0:73d:8b64:5c3 with SMTP id sd12-20020a1709076e0c00b0073d8b6405c3mr2375685ejc.297.1661192228582; Mon, 22 Aug 2022 11:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661192228; cv=none; d=google.com; s=arc-20160816; b=Q3cO+azSZRH+DgBELPM31omVZj4HZziL4M8jIXnq79EQ0vt9qTsCJcQVsDsPCJocA2 6FTxs+Q58gJjPqlVbzm15msDWCijKLZ01/Gx00/ErY6CQHkCodzYX57XusfGrtURL2U5 +eJhxXSQU1eip8gqNWNJ4kQM/d5dGPzhBu66bk4yFRHm8+7aQVS+UHFgWUlejkjD8i8U h3d3hkNXyykDA1uoXGYi10luQBQp67U6H6jzENZbUjaJPM+hdPyAy+ZWrGW0574LjypE 0QtL3Pvsw2JFemxKwhlz94p6KEgEOBufan4PAKRLmZjgkSmwVpBYkDxN0av0R0p0F1Pp IVsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dmarc-filter:delivered-to; bh=EEIRdxltZb9NXhNvpzyfGB5FoY2truarP1iWA+J1Qws=; b=qncYLUWk9Wg4uJ2IPKhYh/pxbs4Jtb/C+J8Z1r8ff13U4FPlPbEJeOb1zR0efxggLi 0kF0S375SLShtKCyZfAKw27bR2cuP2MsZy5jEnyxDLwoZjACHcgqZpu4RQsIlvVrmY5P UQQHv5TeGefJqfbrv2OOb+tPXDT80VkNveO70WXbZNjlpfS+pLDDULX+3+xUh6hNwbdc ePPNvDsPllCCA9rkV3nVvaV1JwScctq9s3Hizqc9nTjiWL72Y/QUuWFXXD1wqRZ7DN8j 6vesnv/MkjTl6LB2DXetN2xkLfhvBnueST7q4ILsHn1Z7ZvGZjobx1Hr3h2ivQkVr0yY AAvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@obs-cr.20210112.gappssmtp.com header.s=20210112 header.b="sYf/3Fmo"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d2-20020aa7d682000000b0044628c209c3si84360edr.632.2022.08.22.11.17.08 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 11:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@obs-cr.20210112.gappssmtp.com header.s=20210112 header.b="sYf/3Fmo"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12F963853559 for <ouuuleilei@gmail.com>; Mon, 22 Aug 2022 18:15:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id DF46C3857BBC for <gcc-patches@gcc.gnu.org>; Mon, 22 Aug 2022 18:15:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF46C3857BBC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=obs.cr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=obs.cr Received: by mail-qk1-x730.google.com with SMTP id j6so8497982qkl.10 for <gcc-patches@gcc.gnu.org>; Mon, 22 Aug 2022 11:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obs-cr.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=EEIRdxltZb9NXhNvpzyfGB5FoY2truarP1iWA+J1Qws=; b=sYf/3FmoDVa5KhSE608BvYRrwwS8OJg23eT3LQCeD0DD6LZG66bFGi/zVV6X4wIaf5 7zp+/lOtkFWB9ZrEwzbm97Q9Lv4utKbtZe9EaYyCY9ZpZGId4YPi5q3saYka7wqwOt/Q dhPN1qjY2ilxSaCRGjXBA8XJvc0pHnWTRJ4BuXMHUNpXGa8f+ACGEcM2UfpC7vz5Vpe5 OEC0dxE+R/xI5iRDoxgNzSIuljNEvOwfITfuJdhvVT0m27guhqjgxeT3pdh3Gw1vRtSv spjpAZDEEEo4fK6N7BCPEbdlWR9++BhCcg9gJyECrJjeChMYbO2LqRb5ERu0wXAV+Br1 X3Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=EEIRdxltZb9NXhNvpzyfGB5FoY2truarP1iWA+J1Qws=; b=xaX8VLYYhkZ00HLqtFI5Dx5ETLCPLZFI5Y8ysX5Eid/PH/Z3LFMlqd/yeE3WT0EULx fq3M+3dFSkxAIzoJl1sXRPgcrrtQpQStR0mbIsGsd7hiU4p6wS2Jpu+S7CCUDWWw6Y8t Xp7031ZCeoJ3YgGEbkrjY3zMFE+Ihb887CIqfwKu5Zp2J0aOWb9JnSIVGwuOLeEIvS+F ABxyVVAMqPPFQKcHfbjEbtsJpw32ow/BqYc/5KdcVOH13spZ6V278yYR3JnNmzVsDGqX uY1LY8FZXQjRMANnsJZVlYOS9iI7ATmzqWAKHxZlRgebjTmwvWH0+ITbd8kZN6ucMq99 SmwQ== X-Gm-Message-State: ACgBeo3HAShy7/ajnhccKb3DGF828D5in/dQa3bwpwtxvwSwJgDCOPMw o12o32MRPWyYYldVf/uFesIjQg== X-Received: by 2002:ae9:ebd6:0:b0:6ba:eb9a:427e with SMTP id b205-20020ae9ebd6000000b006baeb9a427emr13655411qkg.705.1661192124179; Mon, 22 Aug 2022 11:15:24 -0700 (PDT) Received: from localhost.localdomain (ip-192-24-137-251.dynamic.fuse.net. [192.24.137.251]) by smtp.gmail.com with ESMTPSA id do14-20020a05620a2b0e00b006bb0e5ca4bbsm9834049qkb.85.2022.08.22.11.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 11:15:23 -0700 (PDT) From: whh8b@obs.cr To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally Date: Mon, 22 Aug 2022 14:15:09 -0400 Message-Id: <20220822181509.1032874-2-whh8b@obs.cr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822181509.1032874-1-whh8b@obs.cr> References: <20220822181509.1032874-1-whh8b@obs.cr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Cc: Will Hawkins <whh8b@obs.cr> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1741886282648641643?= X-GMAIL-MSGID: =?utf-8?q?1741886302491551144?= |
Series |
libstdc++: Optimize operator+(string/char*, string/char*) equally
|
|
Commit Message
Will Hawkins
Aug. 22, 2022, 6:15 p.m. UTC
From: Will Hawkins <whh8b@obs.cr>
Until now operator+(char*, string) and operator+(string, char*) had
different performance characteristics. The former required a single
memory allocation and the latter required two. This patch makes the
performance equal.
libstdc++-v3/ChangeLog:
* libstdc++-v3/include/bits/basic_string.h (operator+(string, char*)):
Remove naive implementation.
* libstdc++-v3/include/bits/basic_string.tcc (operator+(string, char*)):
Add single-allocation implementation.
---
libstdc++-v3/include/bits/basic_string.h | 7 +------
libstdc++-v3/include/bits/basic_string.tcc | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
Comments
On Mon, 22 Aug 2022 at 19:15, Will Hawkins wrote: > > Until now operator+(char*, string) and operator+(string, char*) had > different performance characteristics. The former required a single > memory allocation and the latter required two. This patch makes the > performance equal. If you don't have a GCC copyright assignment on file with the FSF then please follow the procedure described at https://gcc.gnu.org/dco.html > libstdc++-v3/ChangeLog: > * libstdc++-v3/include/bits/basic_string.h (operator+(string, char*)): > Remove naive implementation. > * libstdc++-v3/include/bits/basic_string.tcc (operator+(string, char*)): > Add single-allocation implementation. > --- > libstdc++-v3/include/bits/basic_string.h | 7 +------ > libstdc++-v3/include/bits/basic_string.tcc | 21 +++++++++++++++++++++ > 2 files changed, 22 insertions(+), 6 deletions(-) > > diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h > index b04fba95678..bc048fc0689 100644 > --- a/libstdc++-v3/include/bits/basic_string.h > +++ b/libstdc++-v3/include/bits/basic_string.h > @@ -3523,12 +3523,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 > _GLIBCXX20_CONSTEXPR > inline basic_string<_CharT, _Traits, _Alloc> Please remove the 'inline' specifier here, since you're moving the definition into the non-inline .tcc file. There's a separate discussion to be had about whether these operator+ overloads *should* be inline. But for the purposes of this change, we want these two operator+ overloads to be consistent, and so they should both be non-inline. > operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, > - const _CharT* __rhs) > - { > - basic_string<_CharT, _Traits, _Alloc> __str(__lhs); > - __str.append(__rhs); > - return __str; > - } > + const _CharT* __rhs); > > /** > * @brief Concatenate string and character. > diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc > index 4563c61429a..95ba8e503e9 100644 > --- a/libstdc++-v3/include/bits/basic_string.tcc > +++ b/libstdc++-v3/include/bits/basic_string.tcc > @@ -640,6 +640,27 @@ _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 > -- > 2.34.1 >
A revision of the original patch -- based on the feedback from Jonathan -- that removes the `inline` specifier is attached.
On Tue, Aug 23, 2022 at 12:33 PM Jonathan Wakely <jwakely@redhat.com> wrote: > > On Mon, 22 Aug 2022 at 19:15, Will Hawkins wrote: > > > > Until now operator+(char*, string) and operator+(string, char*) had > > different performance characteristics. The former required a single > > memory allocation and the latter required two. This patch makes the > > performance equal. > > If you don't have a GCC copyright assignment on file with the FSF then > please follow the procedure described at https://gcc.gnu.org/dco.html Thank you. > > > > libstdc++-v3/ChangeLog: > > * libstdc++-v3/include/bits/basic_string.h (operator+(string, char*)): > > Remove naive implementation. > > * libstdc++-v3/include/bits/basic_string.tcc (operator+(string, char*)): > > Add single-allocation implementation. > > --- > > libstdc++-v3/include/bits/basic_string.h | 7 +------ > > libstdc++-v3/include/bits/basic_string.tcc | 21 +++++++++++++++++++++ > > 2 files changed, 22 insertions(+), 6 deletions(-) > > > > diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h > > index b04fba95678..bc048fc0689 100644 > > --- a/libstdc++-v3/include/bits/basic_string.h > > +++ b/libstdc++-v3/include/bits/basic_string.h > > @@ -3523,12 +3523,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 > > _GLIBCXX20_CONSTEXPR > > inline basic_string<_CharT, _Traits, _Alloc> > > Please remove the 'inline' specifier here, since you're moving the > definition into the non-inline .tcc file. > > There's a separate discussion to be had about whether these operator+ > overloads *should* be inline. But for the purposes of this change, we > want these two operator+ overloads to be consistent, and so they > should both be non-inline. Thank you for the feedback. I sent out a v2 of the patch. Again, I hope that I followed the proper procedure by having my mailer put the patch in reply to my previous message. Thank you again! Will > > > operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, > > - const _CharT* __rhs) > > - { > > - basic_string<_CharT, _Traits, _Alloc> __str(__lhs); > > - __str.append(__rhs); > > - return __str; > > - } > > + const _CharT* __rhs); > > > > /** > > * @brief Concatenate string and character. > > diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc > > index 4563c61429a..95ba8e503e9 100644 > > --- a/libstdc++-v3/include/bits/basic_string.tcc > > +++ b/libstdc++-v3/include/bits/basic_string.tcc > > @@ -640,6 +640,27 @@ _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 > > -- > > 2.34.1 > > >
On Wed, 24 Aug 2022 at 07:18, Will Hawkins <hawkinsw@obs.cr> wrote: > > On Tue, Aug 23, 2022 at 12:33 PM Jonathan Wakely <jwakely@redhat.com> wrote: > > > > On Mon, 22 Aug 2022 at 19:15, Will Hawkins wrote: > > > > > > Until now operator+(char*, string) and operator+(string, char*) had > > > different performance characteristics. The former required a single > > > memory allocation and the latter required two. This patch makes the > > > performance equal. > > > > If you don't have a GCC copyright assignment on file with the FSF then > > please follow the procedure described at https://gcc.gnu.org/dco.html > > Thank you. > > > > > > > > libstdc++-v3/ChangeLog: > > > * libstdc++-v3/include/bits/basic_string.h (operator+(string, char*)): > > > Remove naive implementation. > > > * libstdc++-v3/include/bits/basic_string.tcc (operator+(string, char*)): > > > Add single-allocation implementation. > > > --- > > > libstdc++-v3/include/bits/basic_string.h | 7 +------ > > > libstdc++-v3/include/bits/basic_string.tcc | 21 +++++++++++++++++++++ > > > 2 files changed, 22 insertions(+), 6 deletions(-) > > > > > > diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h > > > index b04fba95678..bc048fc0689 100644 > > > --- a/libstdc++-v3/include/bits/basic_string.h > > > +++ b/libstdc++-v3/include/bits/basic_string.h > > > @@ -3523,12 +3523,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 > > > _GLIBCXX20_CONSTEXPR > > > inline basic_string<_CharT, _Traits, _Alloc> > > > > Please remove the 'inline' specifier here, since you're moving the > > definition into the non-inline .tcc file. > > > > There's a separate discussion to be had about whether these operator+ > > overloads *should* be inline. But for the purposes of this change, we > > want these two operator+ overloads to be consistent, and so they > > should both be non-inline. > > Thank you for the feedback. I sent out a v2 of the patch. Again, I > hope that I followed the proper procedure by having my mailer put the > patch in reply to my previous message. It looks like the patch got attached in this thread, not the [PATCH v2] thread: https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600176.html Presumably it was meant as a reply to: https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600175.html It's more conventional to put the patch in the same email, not as a separate reply, which would avoid that problem. You can use git scissors to separate the patch submission from the preceding discussion and comments, see https://git-scm.com/docs/git-mailinfo#Documentation/git-mailinfo.txt---scissors For example, see my patches like the one at https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600109.html where the "informational" part comes first, describing where it was tested, then the patch (and its commit msg) come after the -- >8 -- scissors. If you use git send-email to send mails, you can use --in-reply-to=$MessageId to make the email a reply to the specified $MessageId from a previous mail in the thread. Anyway, the v2 patch looks fine and I'll apply it to trunk after testing - thanks!
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index b04fba95678..bc048fc0689 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -3523,12 +3523,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, - const _CharT* __rhs) - { - basic_string<_CharT, _Traits, _Alloc> __str(__lhs); - __str.append(__rhs); - return __str; - } + const _CharT* __rhs); /** * @brief Concatenate string and character. diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 4563c61429a..95ba8e503e9 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -640,6 +640,27 @@ _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