public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Refactor cooked_index::do_finalize
@ 2022-12-01 18:18 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-12-01 18:18 UTC (permalink / raw)
To: gdb-cvs
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 ();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-01 18:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 18:18 [binutils-gdb] Refactor cooked_index::do_finalize Tom Tromey
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).