diff options
author | Tom Tromey <tromey@adacore.com> | 2024-02-14 08:00:03 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-03-18 08:10:06 -0600 |
commit | 2b5f0fe3230f707ab736d759af4bf436d2c43837 (patch) | |
tree | 850ef712e8122c65b3bdeba5f2c947ecba9de4a7 /gdb | |
parent | a8e1e2aaf8783092b74330e2d4c727f814533cc9 (diff) | |
download | gdb-2b5f0fe3230f707ab736d759af4bf436d2c43837.zip gdb-2b5f0fe3230f707ab736d759af4bf436d2c43837.tar.gz gdb-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')
-rw-r--r-- | gdb/dwarf2/read.c | 2 |
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) |