aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-02-14 08:00:03 -0700
committerTom Tromey <tromey@adacore.com>2024-03-18 08:10:06 -0600
commit2b5f0fe3230f707ab736d759af4bf436d2c43837 (patch)
tree850ef712e8122c65b3bdeba5f2c947ecba9de4a7 /gdb/dwarf2/read.c
parenta8e1e2aaf8783092b74330e2d4c727f814533cc9 (diff)
downloadbinutils-2b5f0fe3230f707ab736d759af4bf436d2c43837.zip
binutils-2b5f0fe3230f707ab736d759af4bf436d2c43837.tar.gz
binutils-2b5f0fe3230f707ab736d759af4bf436d2c43837.tar.bz2
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.
Diffstat (limited to 'gdb/dwarf2/read.c')
-rw-r--r--gdb/dwarf2/read.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4afb026..65b1671 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)