]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Hoist lambda in linespec.c:add_matching_symbols_to_info
authorTom Tromey <tom@tromey.com>
Wed, 8 Jan 2025 01:29:39 +0000 (18:29 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 11 Jan 2025 18:21:59 +0000 (11:21 -0700)
I noticed that two parts of linespec.c:add_matching_symbols_to_info
use the same lambda, and hoisting this seems slightly more efficient.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/linespec.c

index db979431002cc2048f9fcab52da0066793ef17c5..eb27cb7e2d6706122ac7ae8ab7bab4ad8a44b8aa 100644 (file)
@@ -4250,6 +4250,11 @@ add_matching_symbols_to_info (const char *name,
 {
   lookup_name_info lookup_name (name, name_match_type);
 
+  auto add_symbol = [&] (block_symbol *bsym)
+    {
+      return info->add_symbol (bsym);
+    };
+
   for (const auto &elt : *info->file_symtabs)
     {
       if (elt == nullptr)
@@ -4257,8 +4262,7 @@ add_matching_symbols_to_info (const char *name,
          iterate_over_all_matching_symtabs (info->state, lookup_name,
                                             domain_search_flags,
                                             pspace, true,
-                                            [&] (block_symbol *bsym)
-           { return info->add_symbol (bsym); });
+                                            add_symbol);
          search_minsyms_for_name (info, lookup_name, pspace, NULL);
        }
       else if (pspace == NULL || pspace == elt->compunit ()->objfile ()->pspace ())
@@ -4270,9 +4274,7 @@ add_matching_symbols_to_info (const char *name,
          program_space *elt_pspace = elt->compunit ()->objfile ()->pspace ();
          gdb_assert (!elt_pspace->executing_startup);
          set_current_program_space (elt_pspace);
-         iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT,
-                                   [&] (block_symbol *bsym)
-           { return info->add_symbol (bsym); });
+         iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, add_symbol);
 
          /* If no new symbols were found in this iteration and this symtab
             is in assembler, we might actually be looking for a label for