From patchwork Wed Sep 7 00:45:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp904531wrt; Tue, 6 Sep 2022 17:47:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR5O9X6+rOgcmnwhdKU7sVXfqy2piHtmZhyk9z03ZTarj7o2yAJHRWiPic8OYVM2S0hV32i+ X-Received: by 2002:a17:907:b03:b0:742:a5b2:374f with SMTP id h3-20020a1709070b0300b00742a5b2374fmr683484ejl.396.1662511653397; Tue, 06 Sep 2022 17:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662511653; cv=none; d=google.com; s=arc-20160816; b=IyAO3dQnASbwjSYRJMZgdgKPNd8VrL7LGwr60HK2rKkVVpycdpRCiX8Ve5/4ZKlwtl mHmzB0IkgpWwIl2d5nIjmCke1vD7Jl+8L7XjKJRboqQlFpathOZb57mWBJ6Z+Q1sT8U4 fPNdidVzGdLl432YS/hXS9NS+uGVLJYcZzSRFzs4SSBlUzumgEGmvUwDH9y8vzgp4r+Y NcvAF/S3ZXPB2WEjqjJaZSEKW8QiBm5p/0LWzBUh3LZgXtv+/2u86yEbBcn21qKGhlxP waZWhfyX5Ii/SydNXODxhL/hqwz1u1zNX2ncrwLtwFVYw0RLZU9lbI9xtYb3V4cIEQiR WRLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=zLsjmdzYJ5UWxsycrZY82aRiepATS2WhtFcuz/DMovY=; b=YIJGooixOkJt1G18YeB3aA1vdgCqT9B/JVqYKvgszdFqGuC+zrdq/kAmpmP8mcpv1b MEwmLeDelgx3Da9GveZHK5I4ohIE/lCc4rlu97En/H/uRF6OGvBhOn3V5GY/9YZCm1Ql rHeZSKXaE4xUKHYbdf9KC7Cir8j2Mttggr6QtCKfyabh1iFqsWY9y/bdCKi/z4h9irwT S4oqnv6OHeUOFfnns3zkLj3AQeyJw9Lv+lW9LFB3S7QLnNSVdVHHwY6ttwRR+PNNVaaZ c6JbSVGU+XM/kJ3wzL7W+3BB/++CHU/fx8AHUJjO39WKeKq6ur8mfuVgholWH1DpUVyn 0Krw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qOPvyFq3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h4-20020a0564020e8400b0044dbb9afe1fsi7117604eda.467.2022.09.06.17.47.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 17:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qOPvyFq3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 E0035383BD5B for ; Wed, 7 Sep 2022 00:46:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0035383BD5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662511593; bh=zLsjmdzYJ5UWxsycrZY82aRiepATS2WhtFcuz/DMovY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=qOPvyFq38BrXl2MrlTNkn9s6BBZOsACyCtv+WzS5dYGcR6gWVazGSessyAn/Gs3Wy 0bOSWSvJJSNEQO9+Z4sSSL4oWH0Dp0mi14ce+Azt6ws7GZRdDpsx4jhdOU53saMSEv kxX+vl6J9c8QzVYyFZPx9KMT3y76MFYXAqA7Bq+I= 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 ESMTPS id 2DDF73858297 for ; Wed, 7 Sep 2022 00:45:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2DDF73858297 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-444-z4Y8Tv_iMLaV_rs2lblrEw-1; Tue, 06 Sep 2022 20:45:49 -0400 X-MC-Unique: z4Y8Tv_iMLaV_rs2lblrEw-1 Received: by mail-qv1-f69.google.com with SMTP id g4-20020ad45424000000b004a9bb302c85so3887696qvt.22 for ; Tue, 06 Sep 2022 17:45:48 -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:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=zLsjmdzYJ5UWxsycrZY82aRiepATS2WhtFcuz/DMovY=; b=m7MxhmjonW1+Xi0GY5ryxPpWHIIdAOgGPtbw0tNMCoHna8y5sAFYSlRQtrBEGcukQQ e9PT2UNQncOkjAII/ge1TFpiqVRUJ7fNyItdxPVni3QkJfX9H4+CQFTOePhPJ5EDwyuo W59P6XSOODeSe0wQXHaynJqd2ADc/VRBMP+iyUo3WqT6Xpz9eZe2kGiayHAkvqerZc40 7s7gR10Pf5i5szBrUIGYRx06qIZPxxZLn0oxUgAdifIrcEwsYuoT8dTA8atE9mw/4osj vXUtcg2HtC6TEOhS0F+thL5sV4hz9pcDhi5wFCR6+XkbFKYOLkPQGh3cnQHBFgI6maR7 9UNw== X-Gm-Message-State: ACgBeo0b7EKdvArAhecijKURzWxc3WClShGQAnOePMP/+6/f7jpHghf/ qSIsU6AP1tI3Lr/E4+vWUflJ4PkB7SR72bqiJ9kDd1wGXZ0Y9DN3hzuCVTvGcZdLwqLX5zM/tG0 I7rfzXr7shksbEJsS8hWu69Dp63Gq0snu/8vd5yTarHGOpHCzUT3ubEta5imsa9RN4OY= X-Received: by 2002:ac8:6c4:0:b0:355:8fd:21a0 with SMTP id j4-20020ac806c4000000b0035508fd21a0mr1196608qth.235.1662511548336; Tue, 06 Sep 2022 17:45:48 -0700 (PDT) X-Received: by 2002:ac8:6c4:0:b0:355:8fd:21a0 with SMTP id j4-20020ac806c4000000b0035508fd21a0mr1196587qth.235.1662511548063; Tue, 06 Sep 2022 17:45:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 17:45:47 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] libstdc++: Optimize is_reference Date: Tue, 6 Sep 2022 20:45:42 -0400 Message-Id: <20220907004542.288365-2-ppalka@redhat.com> X-Mailer: git-send-email 2.37.3.518.g79f2338b37 In-Reply-To: <20220907004542.288365-1-ppalka@redhat.com> References: <20220907004542.288365-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org 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?1743269819524898300?= X-GMAIL-MSGID: =?utf-8?q?1743269819524898300?= Instead of defining is_reference in terms of is_lvalue_reference and is_rvalue_reference, just define it directly. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? This reduces memory usage of join.cc by 1%. libstdc++-v3/ChangeLog: * include/std/type_traits (is_reference): Make the primary template derive from false_type. Define two partial specializations that derive from true_type. --- libstdc++-v3/include/std/type_traits | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b83e7257a9f..94e73eafd2f 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -611,8 +611,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_reference template struct is_reference - : public __or_, - is_rvalue_reference<_Tp>>::type + : public false_type + { }; + + template + struct is_reference<_Tp&> + : public true_type + { }; + + template + struct is_reference<_Tp&&> + : public true_type { }; /// is_arithmetic