public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Refactor cooked_index::do_finalize
Date: Thu,  1 Dec 2022 18:18:47 +0000 (GMT)	[thread overview]
Message-ID: <20221201181847.06E633858C3A@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bed34ce7058b56d3a1e171de31df2a0a30afb8fd

commit bed34ce7058b56d3a1e171de31df2a0a30afb8fd
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Nov 4 14:11:56 2022 -0600

    Refactor cooked_index::do_finalize
    
    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.
    
    Reviewed-by: Andrew Burgess <aburgess@redhat.com>

Diff:
---
 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 ();

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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221201181847.06E633858C3A@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.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).