1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

Meta: Do not hard-code index types for UCD/CLDR/TZDB code generators

Hand-picking the smallest index type that fits a particular generated
array started with commit 3ad159537e. This
was to reduce the size of the generated library.

Since then, the number of types using UniqueStorage has grown a ton,
creating a long list of types for which index types are manually picked.
When a new UCD/CLDR/TZDB is released, and the current index type no
longer fits the generated data, we fail to generate. Tracking down which
index caused the failure is a pretty annoying process.

Instead, we can just use size_t while in the generators themselves, then
automatically pick the size needed for the generated code.
This commit is contained in:
Timothy Flynn 2022-11-18 11:04:33 -05:00 committed by Linus Groh
parent fa2579ffa9
commit b2164ad979
9 changed files with 268 additions and 379 deletions

View file

@ -19,8 +19,6 @@
#include <LibCore/Stream.h>
#include <LibLocale/PluralRules.h>
using StringIndexType = u16;
static String format_identifier(StringView owner, String identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
@ -214,7 +212,7 @@ struct LocaleData {
};
struct CLDR {
UniqueStringStorage<StringIndexType> unique_strings;
UniqueStringStorage unique_strings;
HashMap<String, LocaleData> locales;
};
@ -404,7 +402,7 @@ static ErrorOr<void> parse_all_locales(String core_path, String locale_names_pat
VERIFY(Core::File::is_directory(core_supplemental_path.string()));
auto remove_variants_from_path = [&](String path) -> ErrorOr<String> {
auto parsed_locale = TRY(CanonicalLanguageID<StringIndexType>::parse(cldr.unique_strings, LexicalPath::basename(path)));
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
builder.append(cldr.unique_strings.get(parsed_locale.language));