public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Antony Polukhin <antoshkka@gmail.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
	gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Optimize seed_seq construction
Date: Tue, 17 Aug 2021 16:40:37 +0300	[thread overview]
Message-ID: <CAKqmYPaK+DM+CUFCboWyV018LYN9jwzTsvEt1-7BVaw_hUS6sQ@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4=4E_+4ugV5RbzNMFCmAfnot_cW0s52JDfmCjkoD=0Ljw@mail.gmail.com>

вт, 17 авг. 2021 г. в 16:37, Jonathan Wakely <jwakely@redhat.com>:
<...>
> Thanks, this is a nice improvement. We can avoid tag dispatching to
> make it simpler though:
>
> @@ -3248,6 +3249,9 @@ namespace __detail
>   template<typename _InputIterator>
>     seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end)
>     {
> +      if _GLIBCXX17_CONSTEXPR
> (__is_random_access_iter<_InputIterator>::value)
> +       _M_v.reserve(std::distance(__begin, __end));
> +
>       for (_InputIterator __iter = __begin; __iter != __end; ++__iter)
>        _M_v.push_back(__detail::__mod<result_type,
>                       __detail::_Shift<result_type, 32>::__value>(*__iter));
>
> The call to std::distance is well-formed for input iterators, but we
> won't actually call it unless we have random access iterators.
>
> Unless you see a problem with this that I'm missing, I'll go with that version.

Looks much better. Thanks!

-- 
Best regards,
Antony Polukhin

  reply	other threads:[~2021-08-17 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  8:41 Antony Polukhin
2021-08-17 13:36 ` Jonathan Wakely
2021-08-17 13:40   ` Antony Polukhin [this message]
2021-08-17 16:23     ` 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=CAKqmYPaK+DM+CUFCboWyV018LYN9jwzTsvEt1-7BVaw_hUS6sQ@mail.gmail.com \
    --to=antoshkka@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --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).