[2/2] Simplify psymbol_functions::expand_symtabs_matching

Message ID 20210324201510.23655-3-tom@tromey.com
State New
Headers show
Series
  • Two minor partial symtab cleanups
Related show

Commit Message

Tom Tromey March 24, 2021, 8:15 p.m.
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-24  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_functions::expand_symtabs_matching): Only
	call make_ignore_params once.
---
 gdb/ChangeLog | 5 +++++
 gdb/psymtab.c | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

-- 
2.26.2

Comments

Kumar N, Bhuvanendra via Gdb-patches March 25, 2021, 7:31 p.m. | #1
On 2021-03-24 4:15 p.m., Tom Tromey wrote:
> 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-24  Tom Tromey  <tom@tromey.com>

> 

> 	* psymtab.c (psymbol_functions::expand_symtabs_matching): Only

> 	call make_ignore_params once.

> ---

>  gdb/ChangeLog | 5 +++++

>  gdb/psymtab.c | 6 +++++-

>  2 files changed, 10 insertions(+), 1 deletion(-)

> 

> diff --git a/gdb/psymtab.c b/gdb/psymtab.c

> index 5a64166d983..1ea7376a8c8 100644

> --- a/gdb/psymtab.c

> +++ b/gdb/psymtab.c

> @@ -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 =

> 


This LGTM, thanks.

Simon

Patch

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 5a64166d983..1ea7376a8c8 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -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 =