]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
More O(N) elimination
authorPedro Alves <palves@redhat.com>
Tue, 29 Mar 2016 14:48:28 +0000 (15:48 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 19 Sep 2016 14:44:42 +0000 (15:44 +0100)
gdb/linespec.c
gdb/symtab.c
gdb/symtab.h

index 611017e2b983ddcf20fb7adbc48829483f59b042..69d7905a9f66e987bf7270b03e1f2d8c947e9a82 100644 (file)
@@ -3266,15 +3266,7 @@ collect_symtabs_from_filename (const char *file,
                                        NULL);
   cleanups = make_cleanup_htab_delete (collector.symtab_table);
 
-  /* Find that file's data.  */
-  ALL_SEARCH_PSPACES (search_scope->pspace, pspace)
-    {
-      if (pspace->executing_startup)
-       continue;
-
-      set_current_program_space (pspace);
-      iterate_over_symtabs (file, add_symtabs_to_list, &collector);
-    }
+  iterate_over_symtabs (search_scope, file, add_symtabs_to_list, &collector);
 
   do_cleanups (cleanups);
   return collector.symtabs;
index 5dd97cfdf6f9d0b673fd2b0d57da971d945944e0..9d37dec6a7bd627d1b79444cb68c5487c6184e09 100644 (file)
@@ -457,11 +457,13 @@ iterate_over_some_symtabs (const char *name,
    DATA.  If CALLBACK returns true, the search stops.  */
 
 void
-iterate_over_symtabs (const char *name,
+iterate_over_symtabs (struct sym_search_scope *search_scope,
+                     const char *name,
                      int (*callback) (struct symtab *symtab,
                                       void *data),
                      void *data)
 {
+  struct program_space *pspace;
   struct objfile *objfile;
   char *real_path = NULL;
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
@@ -475,7 +477,7 @@ iterate_over_symtabs (const char *name,
       gdb_assert (IS_ABSOLUTE_PATH (real_path));
     }
 
-  ALL_OBJFILES (objfile)
+  ALL_SEARCH_SCOPE_OBJFILES (search_scope, pspace, objfile)
   {
     if (iterate_over_some_symtabs (name, real_path, callback, data,
                                   objfile->compunit_symtabs, NULL))
@@ -488,7 +490,7 @@ iterate_over_symtabs (const char *name,
   /* Same search rules as above apply here, but now we look thru the
      psymtabs.  */
 
-  ALL_OBJFILES (objfile)
+  ALL_SEARCH_SCOPE_OBJFILES (search_scope, pspace, objfile)
   {
     if (objfile->sf
        && objfile->sf->qf->map_symtabs_matching_filename (objfile,
@@ -523,8 +525,10 @@ struct symtab *
 lookup_symtab (const char *name)
 {
   struct symtab *result = NULL;
+  struct sym_search_scope search_scope = null_search_scope ();
 
-  iterate_over_symtabs (name, lookup_symtab_callback, &result);
+  search_scope.pspace = current_program_space;
+  iterate_over_symtabs (&search_scope, name, lookup_symtab_callback, &result);
   return result;
 }
 
index 9f7550741a42cba66db3e4467a9d21fb77510deb..20c6b0214a313f199b1f3d04b086a23f42dd7696 100644 (file)
@@ -1638,7 +1638,8 @@ int iterate_over_some_symtabs (const char *name,
                               struct compunit_symtab *first,
                               struct compunit_symtab *after_last);
 
-void iterate_over_symtabs (const char *name,
+void iterate_over_symtabs (struct sym_search_scope *search_scope,
+                          const char *name,
                           int (*callback) (struct symtab *symtab,
                                            void *data),
                           void *data);