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.129.124]) by sourceware.org (Postfix) with ESMTPS id AD356385C32C for ; Wed, 24 Aug 2022 14:24:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD356385C32C 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=1661351066; 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=UA91szy/HyGVeXja00eC/eit5OeDV7AYnAzpQdDytoUJVyfwS7CGm2i+tyLkGXvJhcuDyN /GRsoFfk3ijLRUEfO47FKfTMveNZgbD1GcXGnaJfpHx/OE7CXBbQxcp/ppkRA2OQFURHbY ARnWFdaeDBetEZN96BV39/efzwXrFWM= 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-197-2CHfX3-SPSWdFxcOuAqvsw-1; Wed, 24 Aug 2022 10:24:23 -0400 X-MC-Unique: 2CHfX3-SPSWdFxcOuAqvsw-1 Received: by mail-qk1-f199.google.com with SMTP id g6-20020a05620a40c600b006bbdeb0b1f2so12088706qko.22 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=EzmMmUyOJnsyhDKu1Bpl5/pJZU3/vR5zDv/PxG3AQe7liUTZ6s0WuAEWK/mWs0BGpK HGeplGypqkfYAv17k3BPnem4E2ZqG61nyrwvDsaZj7SL/J11XBJNQY3ElVjVmFM6okXF Gef5KWN9o6NFNyJur117xW048iWLf4lRiDdRltJbCCgodE7wWoR3BQlmAbqHQIA8q28Y /BK0dLVptx+abYqPTYLsdKA+i9wdP4/5ui1n7Y9j/AzJCDycC63AjTU7fM7qLthY2ku0 H6y+IATTBJvebd5GFEBtdtDyMZ+lYvU1sgeWix72qJc9D9gBN6VYLc4rkAQS7a2uRAVP 2pzQ== X-Gm-Message-State: ACgBeo0en7tLhE5gYiN86U4IOiKXcbBX6Hl4PtFPXns2tPTypZdSMHWJ KQW7glgjWpk++7A8CEX3TDhh7gPZgniaXgOFAsA8I2TFKFIIZteTevW6dPw8iG/1cVEBbqR4DW5 eNWFhvrN4bQUC7NGYomRWBdeXfOi/6dk= X-Received: by 2002:a05:622a:11c2:b0:343:69d:65b2 with SMTP id n2-20020a05622a11c200b00343069d65b2mr24280269qtk.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.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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!