]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove ctf_tid_key
authorTom Tromey <tom@tromey.com>
Sun, 14 Sep 2025 20:45:46 +0000 (14:45 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 5 Oct 2025 20:59:01 +0000 (14:59 -0600)
ctfread.c creates two per-objfile registry keys.  However, one is
sufficient.  This patch combines the two.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ctfread.c

index 44870b957867877db3b6bad4db960374e57af6b0..5bba9d3a3c1cc0454efb55d9c0ba41a3a932ec26 100644 (file)
 
 using ctf_type_map = gdb::unordered_map<ctf_id_t, struct type *>;
 
-static const registry<objfile>::key<ctf_type_map> ctf_tid_key;
-
 struct ctf_fp_info
 {
   explicit ctf_fp_info (ctf_dict_t *cfp) : fp (cfp) {}
   ~ctf_fp_info ();
+
+  /* Map from IDs to types.  */
+  ctf_type_map type_map;
+
+  /* The dictionary.  */
   ctf_dict_t *fp;
 };
 
@@ -211,10 +214,9 @@ static struct symbol *new_symbol (struct ctf_context *cp, struct type *type,
 static struct type *
 set_tid_type (struct objfile *of, ctf_id_t tid, struct type *typ)
 {
-  ctf_type_map *tab = ctf_tid_key.get (of);
-  if (tab == nullptr)
-    tab = ctf_tid_key.emplace (of);
-  tab->emplace (tid, typ);
+  ctf_fp_info *info = ctf_dict_key.get (of);
+  gdb_assert (info != nullptr);
+  info->type_map.emplace (tid, typ);
   return typ;
 }
 
@@ -224,12 +226,11 @@ set_tid_type (struct objfile *of, ctf_id_t tid, struct type *typ)
 static struct type *
 get_tid_type (struct objfile *of, ctf_id_t tid)
 {
-  ctf_type_map *tab = ctf_tid_key.get (of);
-  if (tab == nullptr)
-    return nullptr;
+  ctf_fp_info *info = ctf_dict_key.get (of);
+  gdb_assert (info != nullptr);
 
-  auto iter = tab->find (tid);
-  if (iter == tab->end ())
+  auto iter = info->type_map.find (tid);
+  if (iter == info->type_map.end ())
     return nullptr;
   return iter->second;
 }