diff options
author | Tom Tromey <tromey@adacore.com> | 2021-12-06 12:20:28 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2021-12-07 11:12:12 -0700 |
commit | c5a9fcdfeea5e961b8f73417c213fa570c8affb6 (patch) | |
tree | 380f7224b155f21b5e1142a494790618b9d83fb8 /gdb | |
parent | 4281b0c8fcb19325496094491ce1e046a6401a36 (diff) | |
download | gdb-c5a9fcdfeea5e961b8f73417c213fa570c8affb6.zip gdb-c5a9fcdfeea5e961b8f73417c213fa570c8affb6.tar.gz gdb-c5a9fcdfeea5e961b8f73417c213fa570c8affb6.tar.bz2 |
Avoid extra work in global_symbol_searcher::expand_symtabs
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/symtab.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 3f2eb64..68b6267 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) { |