From patchwork Fri Sep 16 16:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1256 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp829152wrt; Fri, 16 Sep 2022 09:20:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VaiQO37CQaACE6MpRt9xR8+seNG/DBzSEY5t2H16BOfeWS2AW0dmPqA+5DpBBFVYymw37 X-Received: by 2002:a17:906:9b92:b0:780:1f91:30fc with SMTP id dd18-20020a1709069b9200b007801f9130fcmr4290178ejc.142.1663345234594; Fri, 16 Sep 2022 09:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663345234; cv=none; d=google.com; s=arc-20160816; b=OzGre6wn9Gdxy5yk0B99/1ldpUipdiopOLUDLpe6g4iB0sSWis4jsWGf/rAkISPxWP E5Uo/Y7bH3Q38rA8xbDr4+/Q47PWcQ578Nxe9IvMcPc83vdp8RrdOBE1pzz+qkzDtP5L t+P5ZFge7FXFcz+BUOC8xcDkdTaRxCG6DAfZQz81iaORA1ftn1h3Z8kEdelGgEdlSHpf 0TAjBYbB7RjlVUbHqjgzcWICgijW226zQ4ubQYB44xwiNiyA+Rf/FysAITHE85RM1Z2b l4t84ybm8G+61W0ndAWFY8dox+jFMymfGlEaXSsOXf7afdoqAjpiy/hMJeEKHNoTCRt+ 3GWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=XShNPri7G+JfXll9nxlKAzIpKF5owYhpZjzaU9KKXrE=; b=fyFX/oM2pUCZOEfqLsBKVUGoCuulxUrefxpR+BLL5H4qI5wvsd31GIwOSqtwrCFsIH umPh4U09P9+54N4CtzwcuHB+EqPyI/LysOq3RChwe8dmT+SY3azc1MuRGyyMuhhp2tb+ uLb60PGCoJC7OO3kW8ktNcJnd9vObpLuC8vUPBFmUn14W5L3tGdn6oUzKwfxdIKp5lJO Ih6EH6xyqQP2c+mWx5f0kJVO8udwTPKYXLQCXy+aycV4h/Afl7YIGO2YGo5HziD6yQbI yK8Gt05USbNNaq4wxmZl/16AtHFjsjsInjIHVB+fKlmvO0qxGRGP7An8OSTEQM8QsOP+ 9tSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=IXOWQcSN; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 8-20020a508e48000000b0044615ee1b6fsi2509498edx.218.2022.09.16.09.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 09:20:34 -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=pass header.i=@gcc.gnu.org header.s=default header.b=IXOWQcSN; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1CC4538A8142 for ; Fri, 16 Sep 2022 16:19:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CC4538A8142 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663345163; bh=XShNPri7G+JfXll9nxlKAzIpKF5owYhpZjzaU9KKXrE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=IXOWQcSNss1ayKqYCTjr0UN9DpIR/sMtUHfw+GBNgJ8VGwQVCQcfHEKCnZ/4mflOF 2FVtce49jBaGEH43mwZCkGxlYtfaELIl5Ge/11P976U95SbRVwMH7D+dAxV5GQxrSR APBORsG9jP2Ux4w9qg1iF1qu7mrd602rUwXwQv6E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 955B938A814B for ; Fri, 16 Sep 2022 16:18:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 955B938A814B Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-mv2veHMzPRGBkauWTbFsLA-1; Fri, 16 Sep 2022 12:18:16 -0400 X-MC-Unique: mv2veHMzPRGBkauWTbFsLA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9784801231; Fri, 16 Sep 2022 16:18:15 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93987140EBF3; Fri, 16 Sep 2022 16:18:15 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Remove __alloc_neq helper Date: Fri, 16 Sep 2022 17:18:14 +0100 Message-Id: <20220916161814.510563-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744143892924799450?= X-GMAIL-MSGID: =?utf-8?q?1744143892924799450?= Tested x86_64-linux, pushed to trunk. -- >8 -- This class template and partial specialization were added 15 years ago to optimize allocator equality comparisons in std::list. I think it's safe to assume that GCC is now capable of optimizing an inline operator!= that just returns false at least as well as an inline member function that just returns false. libstdc++-v3/ChangeLog: * include/bits/allocator.h (__alloc_neq): Remove. * include/bits/stl_list.h (list::_M_check_equal_allocators): Compare allocators directly, without __alloc_neq. --- libstdc++-v3/include/bits/allocator.h | 17 ----------------- libstdc++-v3/include/bits/stl_list.h | 5 ++--- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 28abf13eba9..c39166e24fe 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -298,23 +298,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; - // Optimize for stateless allocators. - template - struct __alloc_neq - { - static bool - _S_do_it(const _Alloc&, const _Alloc&) - { return false; } - }; - - template - struct __alloc_neq<_Alloc, false> - { - static bool - _S_do_it(const _Alloc& __one, const _Alloc& __two) - { return __one != __two; } - }; - #if __cplusplus >= 201103L template, diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index b8bd46191fc..a73ca60df5a 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -2026,10 +2026,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // To implement the splice (and merge) bits of N1599. void - _M_check_equal_allocators(list& __x) _GLIBCXX_NOEXCEPT + _M_check_equal_allocators(const list& __x) _GLIBCXX_NOEXCEPT { - if (std::__alloc_neq:: - _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator())) + if (_M_get_Node_allocator() != __x._M_get_Node_allocator()) __builtin_abort(); }