From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 40DF03858C33 for ; Wed, 24 Aug 2022 14:24:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40DF03858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661351064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SmWDpM/t4Mnwje0UzLqulNKKzEBKCGZsvxQaP9kRrLA=; b=apv430zOflyrGYsEQ8663HPltrANoRHuffpGWlrIH24rBLUKBQgzgnJe2B/o3EvotsydVy bqp4rGeETeHX7Rb0v3YhwbvLD/T0TcoLdKJ4XaA6WFhxtc8+ci4lp9bcOcn633k6qg5rOU jJnwHVAALtSOU4125q0omd6GbMFDUOo= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-452-1PZ-Xh8SMgmANwGGuIMWEQ-1; Wed, 24 Aug 2022 10:24:23 -0400 X-MC-Unique: 1PZ-Xh8SMgmANwGGuIMWEQ-1 Received: by mail-qk1-f199.google.com with SMTP id de4-20020a05620a370400b006a9711bd9f8so14755371qkb.9 for ; Wed, 24 Aug 2022 07:24:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=SmWDpM/t4Mnwje0UzLqulNKKzEBKCGZsvxQaP9kRrLA=; b=BoCzYbpPpla2qwO2rl+y84NxOFaEDwxwyNOB0MXS3afmbTjNzCjjWcxLEC6o/4Tuph UiCldQ4XNYhbWNA4gc0H5Hw7Mt/mFXh57993oy5dKDnIscNN4P51aR4SXNxt4Ox7EAKY Z9ctS1ek6T00Iw8VdRTLaO9sHu4/LY/tuO8Av14rgy6d+gcKoMy0QOL1Ae5VwsypiOFx tdGnaIsBdHslERV0kyKxyaTlwkVT5dDc0111O5rQ+n2Rk24pKfv8oOFRPzvU5RobSM0S PDI04/TkvblyQCdpbST1wfGh60Ypa0jiv2Euue6z6vGiidNpd6HIoOm/uwyHdW/uS5Yh WTQg== X-Gm-Message-State: ACgBeo2dhImPLlLu6BWlVQBMcFHRwLXLHFJMG0GyrelyGjfTuRgytcA/ XbUMMBUq6sorXygys+PyUu+kXux6ISSsfXedKZplSKoG7EWTYmmunlERXTMvagLNfx25RLk3NH+ htywo6IvoaAb6ejKKlKnCC3zqi7lCDrbhyg== X-Received: by 2002:a05:622a:11c2:b0:343:69d:65b2 with SMTP id n2-20020a05622a11c200b00343069d65b2mr24280271qtk.491.1661351062707; Wed, 24 Aug 2022 07:24:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6eV4WpNi05+iY3pbi1zz4gfYC1606RrmSreUBvK2Ie6MifB6DCibPKYrYvg8+ePEL8ARXdPbuQinHbxDivERo= X-Received: by 2002:a05:622a:11c2:b0:343:69d:65b2 with SMTP id n2-20020a05622a11c200b00343069d65b2mr24280249qtk.491.1661351062511; Wed, 24 Aug 2022 07:24:22 -0700 (PDT) MIME-Version: 1.0 References: <20220822181509.1032874-2-whh8b@obs.cr> <20220824061648.1119635-1-whh8b@obs.cr> <20220824061648.1119635-2-whh8b@obs.cr> In-Reply-To: <20220824061648.1119635-2-whh8b@obs.cr> From: Jonathan Wakely Date: Wed, 24 Aug 2022 15:24:11 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally To: whh8b@obs.cr Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,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 List-Id: On Wed, 24 Aug 2022 at 07:17, 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. > > libstdc++-v3/ChangeLog: There should be a blank line here. > * libstdc++-v3/include/bits/basic_string.h (operator+(string, char*)): The path should be relative to the ChangeLog, so should not include the libstdc++-v3/ directory component. You can use the git gcc-verify alias to check your commit msgs format before submitting. That runs the same checks as will be used for the server-side hook that decides whether to allow a push. See the customization script described at https://gcc.gnu.org/gitwrite.html#vendor for the alaises. Also, the overload you're changing is operator+(const string&, const char*). The distinction matters, because there is also operator+(string&&, const char*) and what you wrote looks more like that one. So I've committed it with this changelog: libstdc++-v3/ChangeLog: * include/bits/basic_string.h (operator+(const string&, const char*)): Remove naive implementation. * include/bits/basic_string.tcc (operator+(const string&, const char*)): Add single-allocation implementation. Thanks for the patch!