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 997E33858D28 for ; Wed, 7 Sep 2022 00:45:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 997E33858D28 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=1662511548; 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: content-transfer-encoding:content-transfer-encoding; bh=b4uZcVb1yB1//IU5rEE8/SASvFhEs8GgdRtORueOyJM=; b=g34hufCrv7xBHQqvpj55V4rQAJQlKJAaVQRgBnwGMYnzXPQ7ZPkH5gJKeYT9Qu0Fj9kSIi ZuMtQwbTYIgGrqo73FjJP5PPGHFFnztkBUlZxSumlHgVZIdeAgRdG9e317edwvTPNJzVzT rMgLB7Npv5arapcODtLayG9fzi2HbGU= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-477-Om0ZA4z6NS-poWHF2xyX1A-1; Tue, 06 Sep 2022 20:45:47 -0400 X-MC-Unique: Om0ZA4z6NS-poWHF2xyX1A-1 Received: by mail-qt1-f200.google.com with SMTP id o22-20020ac85a56000000b0034481129ce6so10532871qta.19 for ; Tue, 06 Sep 2022 17:45:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=b4uZcVb1yB1//IU5rEE8/SASvFhEs8GgdRtORueOyJM=; b=ySkoWEaemqpYARRNDHZLUbFu9VcZ1SaTDOYADZUxswHnZW0GG1Nc78DW0pTR2PNJsb 5HIBLjdXoVjywwmOSo5dNCiR72IK15jpsotBAmRRdXYPTQQkuKEUOJ6I/ADhgK1iVp6Q LlihIxBgER02Z/DjUbQtPhj72LtVxUWeh41HpxseIwete9U3OastzXFsrL5KeI24S51/ vNtBQhlAaw66+8BPk+4ylNVhxx6yPXlVxwRD8TgM3iqz+jibiYFgSgtSacFQV3J3ZApz Bu/ZiXEooAw7ulwNS56TNAQO/KGiYNaRumAwRZduHaHabutRIwOCuXcJfwRDywBJBiB2 yVKQ== X-Gm-Message-State: ACgBeo0Ouei9C6TgZw5j1yBTSQYz7MnVuCFkLCkllfwjnlAeS0ICLYgj 4EkVkZcp2kj6M8gkkTPddkhL9gSaPTb+WUiD4RUIYr3lXUSacbOFBLv0bOo6j5JDJ7WIkx9jxw8 F9/wO/N5Zkui1hq4= X-Received: by 2002:a05:620a:454b:b0:6bb:63e1:7456 with SMTP id u11-20020a05620a454b00b006bb63e17456mr1058616qkp.328.1662511546668; Tue, 06 Sep 2022 17:45:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR576QOWNcqaq42uZSYTTsD/h04BwipcVH1aJgDHmH4n3rqNp8K293ODdPweo8V1Vq6ba1WwBQ== X-Received: by 2002:a05:620a:454b:b0:6bb:63e1:7456 with SMTP id u11-20020a05620a454b00b006bb63e17456mr1058608qkp.328.1662511546472; Tue, 06 Sep 2022 17:45:46 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id f1-20020a05620a408100b006bbd0ae9c05sm13811852qko.130.2022.09.06.17.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 17:45:46 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer Date: Tue, 6 Sep 2022 20:45:41 -0400 Message-Id: <20220907004542.288365-1-ppalka@redhat.com> X-Mailer: git-send-email 2.37.3.518.g79f2338b37 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-14.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,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: Instead of defining these in terms of a helper class template and the relatively expensive __remove_cv_t, just declare four explicit specializations of the main template, one for each choice of cv-quals. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? The is_void change alone reduces memory usage for join.cc by almost 1%. libstdc++-v3/ChangeLog: * include/std/type_traits (__is_void_helper): Remove. (is_void): Make the primary template derive from false_type, and define four explicit specializations that derive from true_type. (__is_null_pointer_helper, is_null_pointer): Likewise. --- libstdc++-v3/include/std/type_traits | 48 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index e4d167939d9..b83e7257a9f 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -289,23 +289,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __remove_cv_t (std::remove_cv_t for C++11). template using __remove_cv_t = typename remove_cv<_Tp>::type; + /// @endcond // Primary type categories. - template - struct __is_void_helper + /// is_void + template + struct is_void : public false_type { }; template<> - struct __is_void_helper + struct is_void : public true_type { }; - /// @endcond - /// is_void - template - struct is_void - : public __is_void_helper<__remove_cv_t<_Tp>>::type - { }; + template<> + struct is_void + : public true_type { }; + + template<> + struct is_void + : public true_type { }; + + template<> + struct is_void + : public true_type { }; /// @cond undocumented template @@ -571,19 +578,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #define __cpp_lib_is_null_pointer 201309L - template - struct __is_null_pointer_helper + /// is_null_pointer (LWG 2247). + template + struct is_null_pointer : public false_type { }; template<> - struct __is_null_pointer_helper + struct is_null_pointer : public true_type { }; - /// is_null_pointer (LWG 2247). - template - struct is_null_pointer - : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type - { }; + template<> + struct is_null_pointer + : public true_type { }; + + template<> + struct is_null_pointer + : public true_type { }; + + template<> + struct is_null_pointer + : public true_type { }; /// __is_nullptr_t (deprecated extension). /// @deprecated Non-standard. Use `is_null_pointer` instead. -- 2.37.3.518.g79f2338b37