]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Micro-optimize cooked_index_entry::full_name
authorTom Tromey <tom@tromey.com>
Wed, 20 Apr 2022 05:44:50 +0000 (23:44 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 20 Apr 2022 12:21:06 +0000 (06:21 -0600)
I noticed that cooked_index_entry::full_name can return the canonical
string when there is no parent entry.

Regression tested on x86-64 Fedora 34.

gdb/dwarf2/cooked-index.c

index b66ef5a1c6481bd3d1a15448043993058f163d5e..d8a1ab8d30e49830967249e3a804bbb51708bffc 100644 (file)
@@ -50,7 +50,7 @@ eq_entry (const void *a, const void *b)
 const char *
 cooked_index_entry::full_name (struct obstack *storage) const
 {
-  if ((flags & IS_LINKAGE) != 0)
+  if ((flags & IS_LINKAGE) != 0 || parent_entry == nullptr)
     return canonical;
 
   const char *sep = nullptr;
@@ -66,13 +66,12 @@ cooked_index_entry::full_name (struct obstack *storage) const
     case language_ada:
       sep = ".";
       break;
-    }
 
-  if (sep == nullptr)
-    return canonical;
+    default:
+      return canonical;
+    }
 
-  if (parent_entry != nullptr)
-    parent_entry->write_scope (storage, sep);
+  parent_entry->write_scope (storage, sep);
   obstack_grow0 (storage, canonical, strlen (canonical));
   return (const char *) obstack_finish (storage);
 }