public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/2] Change vec<, , vl_embed>::m_vecdata refrences into address ()
Date: Fri, 24 Feb 2023 12:46:46 +0100	[thread overview]
Message-ID: <Y/ijphS/xpNB/tnm@tucnak> (raw)
In-Reply-To: <20230224113245.9645013246@imap2.suse-dmz.suse.de>

On Fri, Feb 24, 2023 at 12:32:45PM +0100, Richard Biener via Gcc-patches wrote:
> --- a/gcc/vec.h
> +++ b/gcc/vec.h
> @@ -614,7 +614,7 @@ public:
>    T *bsearch (const void *key, int (*compar)(const void *, const void *));
>    T *bsearch (const void *key,
>  	      int (*compar)(const void *, const void *, void *), void *);
> -  unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
> +  unsigned lower_bound (const T &, bool (*)(const T &, const T &)) const;

Missing space after (*) while you're there.

> @@ -929,7 +929,7 @@ vec<T, A, vl_embed>::iterate (unsigned ix, T *ptr) const
>  {
>    if (ix < m_vecpfx.m_num)
>      {
> -      *ptr = m_vecdata[ix];
> +      *ptr = address()[ix];

Missing space before ().

> @@ -1118,7 +1118,7 @@ inline void
>  vec<T, A, vl_embed>::unordered_remove (unsigned ix)
>  {
>    gcc_checking_assert (ix < length ());
> -  m_vecdata[ix] = m_vecdata[--m_vecpfx.m_num];
> +  address ()[ix] = address ()[--m_vecpfx.m_num];
>  }

As address () is used twice here, can't we stick it into a temporary
and use twice then?

> @@ -1249,8 +1249,11 @@ vec<T, A, vl_embed>::contains (const T &search) const
>  {
>    unsigned int len = length ();
>    for (unsigned int i = 0; i < len; i++)
> -    if ((*this)[i] == search)
> -      return true;
> +    {
> +      const T *slot = &address ()[i];
> +      if (*slot == search)
> +	return true;

Similarly, can't we do address () once before the loop into a temporary?

>  template<typename T, typename A>
>  unsigned
> -vec<T, A, vl_embed>::lower_bound (T obj, bool (*lessthan)(const T &, const T &))
> +vec<T, A, vl_embed>::lower_bound (const T &obj,
> +				  bool (*lessthan)(const T &, const T &))

) ( while you're at it.

Otherwise LGTM.

	Jakub


  reply	other threads:[~2023-02-24 11:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 11:32 [PATCH 1/2] Change vec<,,vl_embed>::m_vecdata " Richard Biener
2023-02-24 11:46 ` Jakub Jelinek [this message]
2023-02-24 12:25   ` [PATCH 1/2] Change vec<, , vl_embed>::m_vecdata " Richard Biener
2023-02-24 13:46 [PATCH 1/2] Change vec<,,vl_embed>::m_vecdata " Richard Biener
2023-02-24 14:06 ` Jakub Jelinek

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=Y/ijphS/xpNB/tnm@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /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).