From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4YzoMVW5jmks3jgAWB0awg (envelope-from ) for ; Fri, 13 Feb 2026 00:40:37 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=arntpJTx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C75BF1E089; Fri, 13 Feb 2026 00:40:37 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BE9261E089 for ; Fri, 13 Feb 2026 00:40:36 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 43EF04BAD14B for ; Fri, 13 Feb 2026 05:40:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43EF04BAD14B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=arntpJTx Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 574794B9DB48 for ; Fri, 13 Feb 2026 05:39:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 574794B9DB48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 574794B9DB48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770961162; cv=none; b=B2TeDJnSGCTsXYh5lsME26+gTfgkbQFCru1W+vAIhQUuVqcjaT4dTHx66Qzqrxcq1xB7Z4q0MU2OIUH4hcPCskSP6B8aOzefIm8dXLm1UgEQPS2+JyV7V1omeLXS8VT0lP0l/LgvhhXS4/ih2vi66exiL3z87MkOEIo+A7yYUIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770961162; c=relaxed/simple; bh=a6DHWqgV4cfjNv/MwKPJ7oNvEsg8JtkGmEp5qAlZDPA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wl+7nNvGP10DdRLwMtxhvv5tbELM5yBkhfE3qQWLFQM1PAu6VkSui7BTCvb2jtzq0uIsPDISUUua2bbtQ9t4vKOy5X/Yk+b7LvZLyhAiyKNyfv20/huV9pryzCGaJRlMNIZZnKnETPxS/TXVkRF8SWPxo7+CtgcjkM+9QXhE5qY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 574794B9DB48 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 61D5dGws014811 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Feb 2026 00:39:20 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 61D5dGws014811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1770961160; bh=ys08FL2Vhg0EyXzwCFWDag0LHBCpMfY3yzcUM/w3TiM=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=arntpJTxAcWGW5bX3oyGrtFmVSDLvTO3ZEyRWc/Hy6wgoU/VNKyPSXtaZJVpdlCwi dhf9DaojaCN4WdGNRIWkICMRFv4K7v+XOqsba9kkY/QPrOhz135O95Gg7RHx9wUX5b E6YpqR8ACMjrZ+imf8Xg3vQuxBu8jDHpt9JjFHqR7f7IcZ9fylF3E14GCCrA9bNWox vbhv2T8A/U5cWk10NEIA940Ii7gXj9YGdOqP98DiROuw/bZAMEx94qsTscKjslg7Ri Le4KR/4duLYriIaiUD9I2qVO4wPz/2VavQMhmuwmIjFvE59IDoEigONJ9EbXk5kQ74 ZV80KwdimdbZQ== Received: by simark.ca (Postfix) id C11C21E0E1; Fri, 13 Feb 2026 00:39:15 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/4] gdb: use gdb::unordered_string_map throughout Date: Fri, 13 Feb 2026 00:38:51 -0500 Message-ID: <20260213053912.3520505-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260213053912.3520505-1-simon.marchi@polymtl.ca> References: <20260213053912.3520505-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 13 Feb 2026 05:39:16 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi Change all uses of gdb::unordered_map to gdb::unordered_string_map Using unordered_string_map avoids constructing a temporary std::string (possibly with dynamic allocation) when looking up values from `const char *`. I don't see any downsides to using unordered_string_map over unordered_map, even if all the lookups are done using existing std::string objects that would be built anyway. I think there are places where we could refactor the code to avoid constructing unnecessary std::string objects, but that is out of scope for this patch. There should be no change of behavior with this patch. Change-Id: Ic4df78b97f2755d5821bb66942b9e4d9a79a3dc5 --- gdb/ada-exp.y | 2 +- gdb/amdgpu-tdep.c | 2 +- gdb/amdgpu-tdep.h | 2 +- gdb/corelow.c | 6 +++--- gdb/cp-namespace.c | 2 +- gdb/elfread.c | 2 +- gdb/gdb_bfd.c | 2 +- gdb/gdbarch-selftests.c | 2 +- gdb/mi/mi-cmds.c | 2 +- gdb/solib-rocm.c | 4 ++-- gdb/solib-svr4.c | 2 +- gdb/source-cache.h | 2 +- gdb/tui/tui-layout.h | 2 +- gdb/xml-tdesc.c | 2 +- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 771a867c4ae6..e02f1e6d10a2 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -97,7 +97,7 @@ struct ada_parse_state std::vector assignments; /* Track currently active iterated assignment names. */ - gdb::unordered_map> + gdb::unordered_string_map> iterated_associations; auto_obstack temp_space; diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c index fc45623f92b1..5a275165fbb2 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -356,7 +356,7 @@ using amd_dbgapi_register_type_enum_up /* Map type lookup names to types. */ using amd_dbgapi_register_type_map - = gdb::unordered_map; + = gdb::unordered_string_map; /* Parse S as a ULONGEST, raise an error on overflow. */ diff --git a/gdb/amdgpu-tdep.h b/gdb/amdgpu-tdep.h index c0adf55fdf60..5404c2901b54 100644 --- a/gdb/amdgpu-tdep.h +++ b/gdb/amdgpu-tdep.h @@ -78,7 +78,7 @@ struct amdgpu_gdbarch_tdep : gdbarch_tdep_base regnum_map; /* A map of register_class_ids keyed by their name. */ - gdb::unordered_map + gdb::unordered_string_map register_class_map; }; diff --git a/gdb/corelow.c b/gdb/corelow.c index 658ff6e0198c..a28a707c293a 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -124,7 +124,7 @@ struct mapped_file_info /* A type that maps a string to a build-id. */ using string_to_build_id_map - = gdb::unordered_map; + = gdb::unordered_string_map; /* A type that maps a build-id to a string. */ using build_id_to_string_map @@ -402,7 +402,7 @@ core_target::core_target (gdb_bfd_ref_ptr cbfd_ref) void core_target::build_file_mappings () { - gdb::unordered_map bfd_map; + gdb::unordered_string_map bfd_map; gdb::unordered_set unavailable_paths; /* All files mapped into the core file. The key is the filename. */ @@ -2122,7 +2122,7 @@ gdb_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd) }; /* All files mapped into the core file. The key is the filename. */ - gdb::unordered_map mapped_files; + gdb::unordered_string_map mapped_files; /* Get the build-id of the core file. At least on Linux, this will be the build-id for the main executable. If other targets add the diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 2e3c539507cc..efdb2a2c850a 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -349,7 +349,7 @@ cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name, } /* Type used for collecting symbols. Maps names to symbols. */ -using symbol_map = gdb::unordered_map; +using symbol_map = gdb::unordered_string_map; /* This version of the function is internal, use the wrapper unless the list of ambiguous symbols is needed. diff --git a/gdb/elfread.c b/gdb/elfread.c index 010744639118..04e9a986031c 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -660,7 +660,7 @@ elf_rel_plt_read (minimal_symbol_reader &reader, /* Per-objfile cache mapping function names to resolved ifunc addresses. */ -using elf_gnu_ifunc_cache = gdb::unordered_map; +using elf_gnu_ifunc_cache = gdb::unordered_string_map; static const registry::key elf_objfile_gnu_ifunc_cache_data; diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 98ea46677493..1933166b5fbf 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -1241,7 +1241,7 @@ maintenance_info_bfds (const char *arg, int from_tty) struct bfd_inferior_data { - gdb::unordered_map bfd_error_string_counts; + gdb::unordered_string_map bfd_error_string_counts; }; /* Per-inferior data key. */ diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c index 424281134a36..c89ad5ce5fde 100644 --- a/gdb/gdbarch-selftests.c +++ b/gdb/gdbarch-selftests.c @@ -133,7 +133,7 @@ register_name_test (struct gdbarch *gdbarch) scoped_mock_context mockctx (gdbarch); /* Track the number of times each register name appears. */ - gdb::unordered_map name_counts; + gdb::unordered_string_map name_counts; const int num_regs = gdbarch_num_cooked_regs (gdbarch); for (auto regnum = 0; regnum < num_regs; regnum++) diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 552eafbbcbc4..48d85e8785c8 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -26,7 +26,7 @@ /* MI command table (built at run time). */ -static gdb::unordered_map mi_cmd_table; +static gdb::unordered_string_map mi_cmd_table; /* MI command with a pure MI implementation. */ diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index c17d5932b553..291694176821 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -69,7 +69,7 @@ struct rocm_solib_fd_cache }; inferior *m_inferior; - gdb::unordered_map m_cache; + gdb::unordered_string_map m_cache; }; int @@ -102,7 +102,7 @@ rocm_solib_fd_cache::open (const std::string &filename, int rocm_solib_fd_cache::close (int fd, fileio_error *target_errno) { - using cache_val = gdb::unordered_map::value_type; + using cache_val = gdb::unordered_string_map::value_type; auto it = std::find_if (m_cache.begin (), m_cache.end (), [fd](const cache_val &s) { return s.second.fd == fd; }); diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index c8d78fbfc1dd..aeb6cd30f423 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -3753,7 +3753,7 @@ svr4_solib_ops::get_solibs_in_ns (int nsid) const faster, and to be able to remove SOs from the map, to avoid returning the dynamic linker multiple times. */ CORE_ADDR debug_base = info->namespace_id[nsid]; - gdb::unordered_map namespace_solibs; + gdb::unordered_string_map namespace_solibs; for (svr4_so &so : info->solib_lists[debug_base]) namespace_solibs[so.name] = so.lm_info.get (); diff --git a/gdb/source-cache.h b/gdb/source-cache.h index 09f65cea62f4..ab4955e553ed 100644 --- a/gdb/source-cache.h +++ b/gdb/source-cache.h @@ -97,7 +97,7 @@ class source_cache /* The file offset cache. The key is the full name of the source file. */ - gdb::unordered_map> m_offset_cache; + gdb::unordered_string_map> m_offset_cache; /* The list of files where styling failed. */ gdb::unordered_set m_no_styling_files; diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index ca9afbabae6b..536174c784d4 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -367,7 +367,7 @@ typedef std::function window_factory; /* The type for a data structure that maps a window name to that window's factory function. */ -typedef gdb::unordered_map window_types_map; +typedef gdb::unordered_string_map window_types_map; /* Register a new TUI window type. NAME is the name of the window type. FACTORY is a function that can be called to instantiate the diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index ac73708f005d..472c604254a8 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -64,7 +64,7 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher) then we will create unnecessary duplicate gdbarches. See gdbarch_list_lookup_by_info. */ -static gdb::unordered_map xml_cache; +static gdb::unordered_string_map xml_cache; /* Callback data for target description parsing. */ -- 2.53.0