From: Tom Tromey Date: Wed, 14 Feb 2024 15:00:03 +0000 (-0700) Subject: Use string_view in quirk_rust_enum X-Git-Tag: gdb-15-branchpoint~706 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b5f0fe3230f707ab736d759af4bf436d2c43837;p=thirdparty%2Fbinutils-gdb.git 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 --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 discriminant_map; + std::unordered_map discriminant_map; for (int i = 0; i < enum_type->num_fields (); ++i) { if (enum_type->field (i).loc_kind () == FIELD_LOC_KIND_ENUMVAL)