public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Avoid extra work in global_symbol_searcher::expand_symtabs
@ 2021-12-06 19:22 Tom Tromey
  2021-12-07 16:24 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2021-12-06 19:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that global_symbol_searcher::expand_symtabs always passes a
file matcher to expand_symtabs_matching.  However, if 'filenames' is
empty, then this always returns true.  It's slightly more efficient to
pass a null file matcher in this case, because that lets the "quick"
symbol implementations skip any filename checks.

Regression tested on x86-64 Fedora 34.
---
 gdb/symtab.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3f2eb64a7c4..68b6267f878 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4678,11 +4678,16 @@ global_symbol_searcher::expand_symtabs
   enum search_domain kind = m_kind;
   bool found_msymbol = false;
 
+  auto do_file_match = [&] (const char *filename, bool basenames)
+    {
+      return file_matches (filename, filenames, basenames);
+    };
+  gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher = nullptr;
+  if (!filenames.empty ())
+    file_matcher = do_file_match;
+
   objfile->expand_symtabs_matching
-    ([&] (const char *filename, bool basenames)
-     {
-       return file_matches (filename, filenames, basenames);
-     },
+    (file_matcher,
      &lookup_name_info::match_any (),
      [&] (const char *symname)
      {
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Avoid extra work in global_symbol_searcher::expand_symtabs
  2021-12-06 19:22 [PATCH] Avoid extra work in global_symbol_searcher::expand_symtabs Tom Tromey
@ 2021-12-07 16:24 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2021-12-07 16:24 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 12/6/21 8:22 PM, Tom Tromey via Gdb-patches wrote:
> I noticed that global_symbol_searcher::expand_symtabs always passes a
> file matcher to expand_symtabs_matching.  However, if 'filenames' is
> empty, then this always returns true.  It's slightly more efficient to
> pass a null file matcher in this case, because that lets the "quick"
> symbol implementations skip any filename checks.
> 

LGTM.

Thanks,
- Tom

> Regression tested on x86-64 Fedora 34.
> ---
>  gdb/symtab.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 3f2eb64a7c4..68b6267f878 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -4678,11 +4678,16 @@ global_symbol_searcher::expand_symtabs
>    enum search_domain kind = m_kind;
>    bool found_msymbol = false;
>  
> +  auto do_file_match = [&] (const char *filename, bool basenames)
> +    {
> +      return file_matches (filename, filenames, basenames);
> +    };
> +  gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher = nullptr;
> +  if (!filenames.empty ())
> +    file_matcher = do_file_match;
> +
>    objfile->expand_symtabs_matching
> -    ([&] (const char *filename, bool basenames)
> -     {
> -       return file_matches (filename, filenames, basenames);
> -     },
> +    (file_matcher,
>       &lookup_name_info::match_any (),
>       [&] (const char *symname)
>       {
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-07 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 19:22 [PATCH] Avoid extra work in global_symbol_searcher::expand_symtabs Tom Tromey
2021-12-07 16:24 ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).