Simplify calls to init_psymbol_list
[deliverable/binutils-gdb.git] / gdb / psymtab.c
index d5bd5b1b2db44cd540feda0663f2ea85ca67598c..356901f14b75189993c36e456084e76e20641482 100644 (file)
@@ -1469,17 +1469,15 @@ sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst)
 struct partial_symtab *
 start_psymtab_common (struct objfile *objfile,
                      const char *filename,
-                     CORE_ADDR textlow,
-                     std::vector<partial_symbol *> &global_psymbols,
-                     std::vector<partial_symbol *> &static_psymbols)
+                     CORE_ADDR textlow)
 {
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (filename, objfile);
   psymtab->set_text_low (textlow);
   psymtab->set_text_high (psymtab->raw_text_low ()); /* default */
-  psymtab->globals_offset = global_psymbols.size ();
-  psymtab->statics_offset = static_psymbols.size ();
+  psymtab->globals_offset = objfile->global_psymbols.size ();
+  psymtab->statics_offset = objfile->static_psymbols.size ();
   return psymtab;
 }
 
@@ -1640,7 +1638,7 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
                     domain_enum domain,
                     enum address_class theclass,
                     short section,
-                    std::vector<partial_symbol *> *list,
+                    psymbol_placement where,
                     CORE_ADDR coreaddr,
                     enum language language, struct objfile *objfile)
 {
@@ -1653,30 +1651,36 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
                                section, coreaddr, language, objfile, &added);
 
   /* Do not duplicate global partial symbols.  */
-  if (list == &objfile->global_psymbols
-      && !added)
+  if (where == psymbol_placement::GLOBAL && !added)
     return;
 
   /* Save pointer to partial symbol in psymtab, growing symtab if needed.  */
+  std::vector<partial_symbol *> *list
+    = (where == psymbol_placement::STATIC
+       ? &objfile->static_psymbols
+       : &objfile->global_psymbols);
   append_psymbol_to_list (list, psym, objfile);
 }
 
-/* Initialize storage for partial symbols.  */
+/* See psympriv.h.  */
 
 void
 init_psymbol_list (struct objfile *objfile, int total_symbols)
 {
-  /* Free any previously allocated psymbol lists.  */
-  objfile->global_psymbols.clear ();
-  objfile->static_psymbols.clear ();
-
-  /* Current best guess is that approximately a twentieth
-     of the total symbols (in a debugging file) are global or static
-     oriented symbols, then multiply that by slop factor of two.  */
-  objfile->global_psymbols.reserve (total_symbols / 10);
-  objfile->static_psymbols.reserve (total_symbols / 10);
+  if (objfile->global_psymbols.capacity () == 0
+      && objfile->static_psymbols.capacity () == 0)
+    {
+      /* Current best guess is that approximately a twentieth of the
+        total symbols (in a debugging file) are global or static
+        oriented symbols, then multiply that by slop factor of
+        two.  */
+      objfile->global_psymbols.reserve (total_symbols / 10);
+      objfile->static_psymbols.reserve (total_symbols / 10);
+    }
 }
 
+/* See psympriv.h.  */
+
 struct partial_symtab *
 allocate_psymtab (const char *filename, struct objfile *objfile)
 {
This page took 0.023991 seconds and 4 git commands to generate.