public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer
Date: Wed, 7 Sep 2022 09:19:39 +0100	[thread overview]
Message-ID: <CACb0b4nPybTwCYGFkeiHzJS9FfghqSRiHxq+4KAb1rUW93orug@mail.gmail.com> (raw)
In-Reply-To: <20220907004542.288365-1-ppalka@redhat.com>

On Wed, 7 Sept 2022 at 01:46, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> 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?

Yes, and we should do the same for is_void_v and  is_null_pointer_v.
Even though the class templates they instantiate will be cheaper now,
they can still avoid any class template instantiation.

> The is_void change alone reduces memory usage for join.cc by
> almost 1%.

Also in my queue of trait refactoring, but I haven't tested if these
are worth doing yet:

template<typename T>
  struct is_object : is_const<const T>::type { };
template<>
  struct is_object<void> : false_type { };
template<>
  struct is_object<const void> : false_type { };
// and so on for volatile and const volatile

And we could define is_object_v as simply is_const_v<const T> && is_void_v<T>.

Improving is_object should benefit <ranges> and also the is_scalar
change proposed at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96710#c2


      parent reply	other threads:[~2022-09-07  8:19 UTC|newest]

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

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=CACb0b4nPybTwCYGFkeiHzJS9FfghqSRiHxq+4KAb1rUW93orug@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /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).