LibUnicode: Sort generated enums case-insensitively

This hasn't mattered yet by chance, because the source for all enums
contains names of the same case. But the enum generated for hour cycle
regions will have mixed case. Sort them case-insensitively in order to
traverse these names in the same order in both generate_enum and
generate_mapping.
This commit is contained in:
Timothy Flynn 2021-11-29 07:36:42 -05:00 committed by Linus Groh
parent 7872934861
commit 15fc03ef34
Notes: sideshowbarker 2024-07-17 23:22:41 +09:00

View File

@ -247,8 +247,8 @@ Optional<@return_type@> @method_name@(StringView key)
template<typename IdentifierFormatter>
void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector<String>& values, Vector<Alias> aliases = {})
{
quick_sort(values);
quick_sort(aliases, [](auto const& alias1, auto const& alias2) { return alias1.alias < alias2.alias; });
quick_sort(values, [](auto const& value1, auto const& value2) { return value1.to_lowercase() < value2.to_lowercase(); });
quick_sort(aliases, [](auto const& alias1, auto const& alias2) { return alias1.alias.to_lowercase() < alias2.alias.to_lowercase(); });
generator.set("name", name);
generator.set("underlying", ((values.size() + !default_.is_empty()) < 256) ? "u8"sv : "u16"sv);