1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 19:04:59 +00:00

LibTimeZone+LibUnicode: Generate string data with run-length encoding

Currently, the unique string lists are stored in the initialized data
sections of their shared libraries. In order to move the data to the
read-only section, generate the strings using RLE arrays.

We generate two arrays: the first is the RLE data itself, the second is
a list of indices into the RLE array for each string. We then generate a
decoding method to convert an RLE string to a StringView.
This commit is contained in:
Timothy Flynn 2022-08-15 13:01:42 -04:00 committed by Andreas Kling
parent de980de0e4
commit becec3578f
6 changed files with 138 additions and 59 deletions

View file

@ -825,13 +825,13 @@ struct NumberFormatImpl {
number_format.magnitude = magnitude;
number_format.exponent = exponent;
number_format.plurality = static_cast<PluralCategory>(plurality);
number_format.zero_format = s_string_list[zero_format];
number_format.positive_format = s_string_list[positive_format];
number_format.negative_format = s_string_list[negative_format];
number_format.zero_format = decode_string(zero_format);
number_format.positive_format = decode_string(positive_format);
number_format.negative_format = decode_string(negative_format);
number_format.identifiers.ensure_capacity(identifiers.size());
for (@string_index_type@ identifier : identifiers)
number_format.identifiers.append(s_string_list[identifier]);
number_format.identifiers.append(decode_string(identifier));
return number_format;
}
@ -996,7 +996,7 @@ Optional<StringView> get_number_system_symbol(StringView locale, StringView syst
if (symbol_index >= symbols.size())
return {};
return s_string_list[symbols[symbol_index]];
return decode_string(symbols[symbol_index]);
}
return {};
@ -1088,7 +1088,7 @@ static Unit const* find_units(StringView locale, StringView unit)
for (auto unit_index : locale_units) {
auto const& units = s_units.at(unit_index);
if (unit == s_string_list[units.unit])
if (unit == decode_string(units.unit))
return &units;
};