[17/19] Use gdb unordered set and map in cp-namespace.c

Message ID 20250317-replace-std-stuff-v1-17-7ba4ee88e218@tromey.com
State New
Headers
Series Convert std::unordered_{set,map} to gdb implementations |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey March 18, 2025, 2:15 a.m. UTC
  This changes cp-namespace.c to use gdb::unordered_map.
---
 gdb/cp-namespace.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Comments

Simon Marchi March 18, 2025, 3:20 a.m. UTC | #1
On 2025-03-17 22:15, Tom Tromey wrote:
> @@ -391,8 +394,7 @@ cp_lookup_symbol_via_imports (const char *scope,
>  			      const int search_scope_first,
>  			      const int declaration_only,
>  			      const int search_parents,
> -			      std::map<std::string,
> -				       struct block_symbol>& found_symbols)
> +			      symbol_map& found_symbols)

Space before &, I think.

Simon
  
Tom Tromey March 18, 2025, 11:32 a.m. UTC | #2
>> +			      symbol_map& found_symbols)

Simon> Space before &, I think.

Yeah, thanks, I fixed this.

Tom
  

Patch

diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index dc018a2ef286cf84a1b5b38f073849043037faf3..1639cdba967090cc604bec97b929ee69e07268a6 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -32,7 +32,7 @@ 
 #include "language.h"
 #include "namespace.h"
 #include "inferior.h"
-#include <map>
+#include "gdbsupport/unordered_map.h"
 #include <string>
 #include <string.h>
 
@@ -352,6 +352,9 @@  cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
   return sym;
 }
 
+/* Type used for collecting symbols.  Maps names to symbols.  */
+using symbol_map = gdb::unordered_map<std::string, block_symbol>;
+
 /* This version of the function is internal, use the wrapper unless
    the list of ambiguous symbols is needed.
 
@@ -391,8 +394,7 @@  cp_lookup_symbol_via_imports (const char *scope,
 			      const int search_scope_first,
 			      const int declaration_only,
 			      const int search_parents,
-			      std::map<std::string,
-				       struct block_symbol>& found_symbols)
+			      symbol_map& found_symbols)
 {
   struct block_symbol sym = {};
   int len;
@@ -509,7 +511,7 @@  cp_lookup_symbol_via_imports (const char *scope,
 			      const int declaration_only,
 			      const int search_parents)
 {
-  std::map<std::string, struct block_symbol> found_symbols;
+  symbol_map found_symbols;
 
   cp_lookup_symbol_via_imports(scope, name, block, domain, 0,
 			       declaration_only, search_parents,