Simplify psymbol_functions::expand_symtabs_matching
authorTom Tromey <tom@tromey.com>
Fri, 26 Mar 2021 19:28:03 +0000 (13:28 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 26 Mar 2021 19:28:03 +0000 (13:28 -0600)
I noticed that psymbol_functions::expand_symtabs_matching calls
make_ignore_params once per psymtab that is matched.  This seems
possibly expensive, so this patch hoists the call out of the loop.

gdb/ChangeLog
2021-03-26  Tom Tromey  <tom@tromey.com>

* psymtab.c (psymbol_functions::expand_symtabs_matching): Only
call make_ignore_params once.

gdb/ChangeLog
gdb/psymtab.c

index 7955aa4c64ec15389242162f824f4bfdaf532b25..168cd5b9c0505a6677077fad774b031bd745ef7f 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-26  Tom Tromey  <tom@tromey.com>
+
+       * psymtab.c (psymbol_functions::expand_symtabs_matching): Only
+       call make_ignore_params once.
+
 2021-03-26  Tom Tromey  <tom@tromey.com>
 
        * psymtab.c (psymbol_functions::expand_symtabs_matching): Remove
index 5a64166d9831b83c1e10d39622040f33183a150f..1ea7376a8c863c5608c00f92696dca30da1d3696 100644 (file)
@@ -1306,6 +1306,10 @@ psymbol_functions::expand_symtabs_matching
   for (partial_symtab *ps : require_partial_symbols (objfile))
     ps->searched_flag = PST_NOT_SEARCHED;
 
+  gdb::optional<lookup_name_info> psym_lookup_name;
+  if (lookup_name != nullptr)
+    psym_lookup_name = lookup_name->make_ignore_params ();
+
   for (partial_symtab *ps : m_partial_symtabs->range ())
     {
       QUIT;
@@ -1335,7 +1339,7 @@ psymbol_functions::expand_symtabs_matching
 
       if ((symbol_matcher == NULL && lookup_name == NULL)
          || recursively_search_psymtabs (ps, objfile, domain,
-                                         lookup_name->make_ignore_params (),
+                                         *psym_lookup_name,
                                          symbol_matcher))
        {
          struct compunit_symtab *symtab =