summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-01-10 12:23:22 -0500
committerLinus Groh <mail@linusgroh.de>2022-01-11 00:36:45 +0100
commit14535fb67a5cee71b07a83e9f761132107284403 (patch)
tree31c8599be2e5941afa7e2cc9372fdb08c698163e /Meta/Lagom
parentb493c2ca902569fbde6151d3953ac06863c75c7c (diff)
downloadserenity-14535fb67a5cee71b07a83e9f761132107284403.zip
LibTimeZone: Perform time-zone-from-string lookups case insensitively
Time zone names in the TZDB are defined to be case insensitive.
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp
index bdb7ccbdfd..cded014ffe 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp
@@ -235,12 +235,19 @@ namespace TimeZone {
HashValueMap<String> hashes;
hashes.ensure_capacity(values.size());
+ auto hash = [](auto const& value) {
+ return CaseInsensitiveStringViewTraits::hash(value);
+ };
+
for (auto const& value : values)
- hashes.set(value.hash(), format_identifier(enum_title, value));
+ hashes.set(hash(value), format_identifier(enum_title, value));
for (auto const& alias : aliases)
- hashes.set(alias.alias.hash(), format_identifier(enum_title, alias.alias));
+ hashes.set(hash(alias.alias), format_identifier(enum_title, alias.alias));
+
+ ValueFromStringOptions options {};
+ options.sensitivity = CaseSensitivity::CaseInsensitive;
- generate_value_from_string(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes));
+ generate_value_from_string(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes), options);
};
append_from_string("TimeZone"sv, "time_zone"sv, time_zone_data.time_zone_names, time_zone_data.time_zone_aliases);