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
Notes: sideshowbarker 2024-07-17 08:11:40 +09:00
6 changed files with 138 additions and 59 deletions

View file

@ -724,8 +724,8 @@ Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(TimeZone time_zone,
auto format_name = [](auto format, auto offset) -> String {
if (offset == 0)
return s_string_list[format].replace("{}"sv, ""sv, ReplaceMode::FirstOnly);
return String::formatted(s_string_list[format], s_string_list[offset]);
return decode_string(format).replace("{}"sv, ""sv, ReplaceMode::FirstOnly);
return String::formatted(decode_string(format), decode_string(offset));
};
auto set_named_offset = [&](auto& named_offset, auto dst_offset, auto in_dst, auto format, auto offset) {
@ -776,7 +776,7 @@ Vector<StringView> time_zones_in_region(StringView region)
time_zones.ensure_capacity(regional_time_zones.size());
for (auto time_zone : regional_time_zones)
time_zones.unchecked_append(s_string_list[time_zone]);
time_zones.unchecked_append(decode_string(time_zone));
return time_zones;
}