mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 23:15:08 +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:
parent
fa2579ffa9
commit
b2164ad979
9 changed files with 268 additions and 379 deletions
|
@ -15,11 +15,8 @@
|
|||
#include <LibCore/Stream.h>
|
||||
#include <LibUnicode/Emoji.h>
|
||||
|
||||
using StringIndexType = u16;
|
||||
constexpr auto s_string_index_type = "u16"sv;
|
||||
|
||||
struct Emoji {
|
||||
StringIndexType name { 0 };
|
||||
size_t name { 0 };
|
||||
Optional<String> image_path;
|
||||
Unicode::EmojiGroup group;
|
||||
String subgroup;
|
||||
|
@ -31,7 +28,7 @@ struct Emoji {
|
|||
};
|
||||
|
||||
struct EmojiData {
|
||||
UniqueStringStorage<StringIndexType> unique_strings;
|
||||
UniqueStringStorage unique_strings;
|
||||
Vector<Emoji> emojis;
|
||||
};
|
||||
|
||||
|
@ -180,7 +177,7 @@ static ErrorOr<void> generate_emoji_data_implementation(Core::Stream::BufferedFi
|
|||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
||||
generator.set("string_index_type"sv, s_string_index_type);
|
||||
generator.set("string_index_type"sv, emoji_data.unique_strings.type_that_fits());
|
||||
generator.set("emojis_size"sv, String::number(emoji_data.emojis.size()));
|
||||
|
||||
generator.append(R"~~~(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue