Use string_view in quirk_rust_enum
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
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.
---
gdb/dwarf2/read.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:
Tom> quirk_rust_enum makes string copies to store in an unordered_map.
Tom> However, the original strings have an appropriate lifetime, and so no
Tom> copying is needed. With C++17, we can rely on string_view having a
Tom> std::hash specialization, so this patch changes this code to use
Tom> string_view rather than string.
I'm checking this in.
Tom
@@ -5948,7 +5948,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)