public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Use string_view in quirk_rust_enum
@ 2024-03-18 14:16 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-03-18 14:16 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2b5f0fe3230f707ab736d759af4bf436d2c43837

commit 2b5f0fe3230f707ab736d759af4bf436d2c43837
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Feb 14 08:00:03 2024 -0700

    Use string_view in quirk_rust_enum
    
    quirk_rust_enum makes string copies to store in an unordered_map.
    However, the original strings have an appropriate lifetime, and so no
    copying is needed.  With C++17, we can rely on string_view having a
    std::hash specialization, so this patch changes this code to use
    string_view rather than string.

Diff:
---
 gdb/dwarf2/read.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4afb026b8ce..65b16719922 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5955,7 +5955,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
       /* We need a way to find the correct discriminant given a
 	 variant name.  For convenience we build a map here.  */
       struct type *enum_type = disr_field->type ();
-      std::unordered_map<std::string, ULONGEST> discriminant_map;
+      std::unordered_map<std::string_view, ULONGEST> discriminant_map;
       for (int i = 0; i < enum_type->num_fields (); ++i)
 	{
 	  if (enum_type->field (i).loc_kind () == FIELD_LOC_KIND_ENUMVAL)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-18 14:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18 14:16 [binutils-gdb] Use string_view in quirk_rust_enum Tom Tromey

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).