public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, Patrick Palka <ppalka@redhat.com>
Subject: [PATCH 2/2] libstdc++: Optimize is_reference
Date: Tue,  6 Sep 2022 20:45:42 -0400	[thread overview]
Message-ID: <20220907004542.288365-2-ppalka@redhat.com> (raw)
In-Reply-To: <20220907004542.288365-1-ppalka@redhat.com>

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<typename _Tp>
     struct is_reference
-    : public __or_<is_lvalue_reference<_Tp>,
-                   is_rvalue_reference<_Tp>>::type
+    : public false_type
+    { };
+
+  template<typename _Tp>
+    struct is_reference<_Tp&>
+    : public true_type
+    { };
+
+  template<typename _Tp>
+    struct is_reference<_Tp&&>
+    : public true_type
     { };
 
   /// is_arithmetic
-- 
2.37.3.518.g79f2338b37


  reply	other threads:[~2022-09-07  0:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07  0:45 [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer Patrick Palka
2022-09-07  0:45 ` Patrick Palka [this message]
2022-09-07  8:00   ` [PATCH 2/2] libstdc++: Optimize is_reference Jonathan Wakely
2022-09-07  8:19 ` [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220907004542.288365-2-ppalka@redhat.com \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).