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 B2BC63858428 for ; Wed, 7 Sep 2022 00:45:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2BC63858428 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-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-112-e4zD4v9iPXGH1hmZnS9ueA-1; Tue, 06 Sep 2022 20:45:47 -0400 X-MC-Unique: e4zD4v9iPXGH1hmZnS9ueA-1 Received: by mail-qt1-f198.google.com with SMTP id ci6-20020a05622a260600b0034370b6f5d6so10564696qtb.14 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=4G2/9T/AAU7jreroKKnAUgpckKEV4Mz9xYwH3zT2CgdQgpApKzUyPf4YxYC4oLuBRj 0dqeGnjOjzETjoUqrSFbKmGv61G2FlM8/Lz0p8nK1EzAVutgOuDnesARTfFXnQpGnVhl BTfgk1KmoCRXnuPIi9eVCeOJeqePsczN28E+rj70adO1Y8+LSaBebIU452I521ecGhHX ybYFNmIzTVC+snoozLjhX5Mu9IVuYVxCELGK6kTSUXSgOXoteLuEmnGqwUUosM51prGQ m3ORCjE3RxdAzEii/NuUyq0oEQQ/U8AmRY/2nu58Twwabfny50d2iGEyJ8k2U8qjbmPI Jvjw== X-Gm-Message-State: ACgBeo3MccU1hnwL/1+q8QfWquGNYGtbucJ2H1iJ9OcJY52i6FhmIiOu u2BOKRifiA5+OSQN5yJ9GOhRl5ywWyP88uiM5E7pf43Jt0Zd1e86NED8Od2Pt6vvo44etbOmIMZ g9kcMSZbHeMTAMDbytFV5oGOvVOEASqx69aGERAoYfKrYu/pukPzJBI2eQlYjgK+C+OI= X-Received: by 2002:a05:620a:454b:b0:6bb:63e1:7456 with SMTP id u11-20020a05620a454b00b006bb63e17456mr1058620qkp.328.1662511546775; 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.0 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_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: 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