From patchwork Fri Nov 8 15:30:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 2008603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eDOUG/y1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XlNgp4xbMz1xxq for ; Sat, 9 Nov 2024 02:50:30 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFDCE3857B90 for ; Fri, 8 Nov 2024 15:50:28 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTP id D38CA385841E for ; Fri, 8 Nov 2024 15:46:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D38CA385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D38CA385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731080804; cv=none; b=Ayl0BLk76Bsbq2JO0fpvWxc5aLYqn7NMKIWGsV2i9pLDi5GV3bZQDu9jXH0ZeRDVq7H3xC3HBKVREU1l6+00gfZ/mqYpVSQz6QnNz8MZrJqEKB+LGZh0AXYbWwWON6yUlQrIkSCajM5rvB3UPDNrJbb4FnIQXQqfQTNYZIyB4f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731080804; c=relaxed/simple; bh=cnVR1shwoWAWNPq73rOTpMN5XDqv7Ql8zkavD/1y0PA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k2M0GO5SvmtwG724u7xRKF8pYyfszXpXYHUIPcyvY0O3nDPtt5T5YuvnOgMfqLrm1fU7ncMFCzdxsfVulGUwCSM2kdwDFuXnZdFMCt7+iXEVgx8Lz0rs0106zrLVBLm1kj7JsoA+9UdBzijxOreLiCX+tO6oCRg5B8cYjyrjEWo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731080785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gl6eaqo9uQhSUHE7OLy1r64xLFS4Mh96jRt9RlJfcOE=; b=eDOUG/y1gwtLYLq8tZcVfdq0qr1ddq3caLpVIbPC4x/umL+n8S3eDvCALmZpo9M8fMeaOB WLpLiouxf6fYJp5VfQOIXks8DwplJn/0ZQ9qWf++icQBIOhvVXwD7I7EojKq0P9b4XwXLd TrI2jDdqEtePnf+sBQwgqE3D2A4tm2Y= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-Up2y_dxHPOuDi0cIEGF1sg-1; Fri, 08 Nov 2024 10:46:22 -0500 X-MC-Unique: Up2y_dxHPOuDi0cIEGF1sg-1 X-Mimecast-MFC-AGG-ID: Up2y_dxHPOuDi0cIEGF1sg Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9347919560A3; Fri, 8 Nov 2024 15:46:21 +0000 (UTC) Received: from localhost (unknown [10.22.64.104]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 101E81956054; Fri, 8 Nov 2024 15:46:20 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 10/12] libstdc++: Remove _Hashtable_base::_S_equals Date: Fri, 8 Nov 2024 15:30:20 +0000 Message-ID: <20241108154548.813315-11-jwakely@redhat.com> In-Reply-To: <20241108154548.813315-1-jwakely@redhat.com> References: <20241108154548.813315-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: jl_509JLJiSWLdEyXhq1wiGilogKo6aDnH_5r8GsaZM_1731080781 X-Mimecast-Originator: redhat.com X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This removes the overloaded _S_equals and _S_node_equals functions, replacing them with 'if constexpr' in the handful of places they're used. libstdc++-v3/ChangeLog: * include/bits/hashtable_policy.h (_Hashtable_base::_S_equals): Remove. (_Hashtable_base::_S_node_equals): Remove. (_Hashtable_base::_M_key_equals_tr): Fix inaccurate static_assert string. (_Hashtable_base::_M_equals, _Hashtable_base::_M_equals_tr): Use 'if constexpr' instead of _S_equals. (_Hashtable_base::_M_node_equals): Use 'if constexpr' instead of _S_node_equals. --- This one could be pushed independently of the rest of the series. libstdc++-v3/include/bits/hashtable_policy.h | 48 ++++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index c3d89a1101c..ad0dfd55c3f 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1487,24 +1487,6 @@ namespace __detail private: using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>; - static bool - _S_equals(__hash_code, const _Hash_node_code_cache&) - { return true; } - - static bool - _S_node_equals(const _Hash_node_code_cache&, - const _Hash_node_code_cache&) - { return true; } - - static bool - _S_equals(__hash_code __c, const _Hash_node_code_cache& __n) - { return __c == __n._M_hash_code; } - - static bool - _S_node_equals(const _Hash_node_code_cache& __lhn, - const _Hash_node_code_cache& __rhn) - { return __lhn._M_hash_code == __rhn._M_hash_code; } - protected: _Hashtable_base() = default; @@ -1531,31 +1513,49 @@ namespace __detail { static_assert( __is_invocable{}, - "key equality predicate must be invocable with two arguments of " - "key type"); + "key equality predicate must be invocable with the argument type " + "and the key type"); return _M_eq()(__k, _ExtractKey{}(__n._M_v())); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr bool _M_equals(const _Key& __k, __hash_code __c, const _Hash_node_value<_Value, __hash_cached::value>& __n) const - { return _S_equals(__c, __n) && _M_key_equals(__k, __n); } + { + if constexpr (__hash_cached::value) + if (__c != __n._M_hash_code) + return false; + + return _M_key_equals(__k, __n); + } template bool _M_equals_tr(const _Kt& __k, __hash_code __c, const _Hash_node_value<_Value, __hash_cached::value>& __n) const - { return _S_equals(__c, __n) && _M_key_equals_tr(__k, __n); } + { + if constexpr (__hash_cached::value) + if (__c != __n._M_hash_code) + return false; + + return _M_key_equals_tr(__k, __n); + } bool _M_node_equals( const _Hash_node_value<_Value, __hash_cached::value>& __lhn, const _Hash_node_value<_Value, __hash_cached::value>& __rhn) const { - return _S_node_equals(__lhn, __rhn) - && _M_key_equals(_ExtractKey{}(__lhn._M_v()), __rhn); + if constexpr (__hash_cached::value) + if (__lhn._M_hash_code != __rhn._M_hash_code) + return false; + + return _M_key_equals(_ExtractKey{}(__lhn._M_v()), __rhn); } +#pragma GCC diagnostic pop void _M_swap(_Hashtable_base& __x)