public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>,
	gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: Re: [PATCH 2/3] Refactor cooked_index::do_finalize
Date: Thu, 01 Dec 2022 15:34:40 +0000	[thread overview]
Message-ID: <87edtj16jz.fsf@redhat.com> (raw)
In-Reply-To: <20221107162356.3175221-3-tromey@adacore.com>

Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

> This refactors cooked_index::do_finalize, reordering an 'if' to make
> it a little less redundant.  This change makes a subsequent patch
> easier to read.

LGTM.

Thanks,
Andrew

> ---
>  gdb/dwarf2/cooked-index.c | 49 ++++++++++++++++++---------------------
>  1 file changed, 23 insertions(+), 26 deletions(-)
>
> diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
> index adb0046609e..a580d549d0d 100644
> --- a/gdb/dwarf2/cooked-index.c
> +++ b/gdb/dwarf2/cooked-index.c
> @@ -196,16 +196,28 @@ cooked_index::do_finalize ()
>    for (cooked_index_entry *entry : m_entries)
>      {
>        gdb_assert (entry->canonical == nullptr);
> -      if ((entry->per_cu->lang () != language_cplus
> -	   && entry->per_cu->lang () != language_ada)
> -	  || (entry->flags & IS_LINKAGE) != 0)
> +      if ((entry->flags & IS_LINKAGE) != 0)
>  	entry->canonical = entry->name;
> -      else
> +      else if (entry->per_cu->lang () == language_ada)
>  	{
> -	  if (entry->per_cu->lang () == language_ada)
> +	  gdb::unique_xmalloc_ptr<char> canon_name
> +	    = handle_gnat_encoded_entry (entry, gnat_entries.get ());
> +	  if (canon_name == nullptr)
> +	    entry->canonical = entry->name;
> +	  else
> +	    {
> +	      entry->canonical = canon_name.get ();
> +	      m_names.push_back (std::move (canon_name));
> +	    }
> +	}
> +      else if (entry->per_cu->lang () == language_cplus)
> +	{
> +	  void **slot = htab_find_slot (seen_names.get (), entry,
> +					INSERT);
> +	  if (*slot == nullptr)
>  	    {
>  	      gdb::unique_xmalloc_ptr<char> canon_name
> -		= handle_gnat_encoded_entry (entry, gnat_entries.get ());
> +		= cp_canonicalize_string (entry->name);
>  	      if (canon_name == nullptr)
>  		entry->canonical = entry->name;
>  	      else
> @@ -216,28 +228,13 @@ cooked_index::do_finalize ()
>  	    }
>  	  else
>  	    {
> -	      void **slot = htab_find_slot (seen_names.get (), entry,
> -					    INSERT);
> -	      if (*slot == nullptr)
> -		{
> -		  gdb::unique_xmalloc_ptr<char> canon_name
> -		    = cp_canonicalize_string (entry->name);
> -		  if (canon_name == nullptr)
> -		    entry->canonical = entry->name;
> -		  else
> -		    {
> -		      entry->canonical = canon_name.get ();
> -		      m_names.push_back (std::move (canon_name));
> -		    }
> -		}
> -	      else
> -		{
> -		  const cooked_index_entry *other
> -		    = (const cooked_index_entry *) *slot;
> -		  entry->canonical = other->canonical;
> -		}
> +	      const cooked_index_entry *other
> +		= (const cooked_index_entry *) *slot;
> +	      entry->canonical = other->canonical;
>  	    }
>  	}
> +      else
> +	entry->canonical = entry->name;
>      }
>  
>    m_names.shrink_to_fit ();
> -- 
> 2.34.3


  reply	other threads:[~2022-12-01 15:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 16:23 [PATCH 0/3] Fix over-eager CU expansion with new DWARF reader Tom Tromey
2022-11-07 16:23 ` [PATCH 1/3] Remove language check from dwarf2_compute_name Tom Tromey
2022-12-01 15:16   ` Andrew Burgess
2022-11-07 16:23 ` [PATCH 2/3] Refactor cooked_index::do_finalize Tom Tromey
2022-12-01 15:34   ` Andrew Burgess [this message]
2022-11-07 16:23 ` [PATCH 3/3] Add name canonicalization for C Tom Tromey
2022-12-01 16:06   ` Simon Marchi
2022-12-01 16:29   ` Andrew Burgess
2022-12-01 17:56     ` Tom Tromey
2022-12-01 18:16       ` Tom Tromey
2022-12-01 23:23   ` Andrew Burgess
2022-12-02 14:39     ` Tom Tromey

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=87edtj16jz.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.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).