From: Tom Tromey Date: Fri, 4 Nov 2022 20:11:56 +0000 (-0600) Subject: Refactor cooked_index::do_finalize X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bed34ce7058b56d3a1e171de31df2a0a30afb8fd;p=binutils-gdb.git 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 --- 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 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 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 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 ();