mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
LibUnicode: Sort special casing array by locale specificity
This is to simply the Default Case Conversion implementation. Otherwise, the implementation would need to determine which special casing rule to apply, instead of just picking the first match.
This commit is contained in:
parent
12ae0a44d7
commit
077a693de6
Notes:
sideshowbarker
2024-07-18 04:36:49 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/077a693de66 Pull-request: https://github.com/SerenityOS/serenity/pull/9841 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/linusg ✅
|
@ -181,7 +181,6 @@ static void parse_special_casing(Core::File& file, UnicodeData& unicode_data)
|
|||
VERIFY(segments.size() == 5 || segments.size() == 6);
|
||||
|
||||
SpecialCasing casing {};
|
||||
casing.index = static_cast<u32>(unicode_data.special_casing.size());
|
||||
casing.code_point = AK::StringUtils::convert_to_uint_from_hex<u32>(segments[0]).value();
|
||||
casing.lowercase_mapping = parse_code_point_list(segments[1]);
|
||||
casing.titlecase_mapping = parse_code_point_list(segments[2]);
|
||||
|
@ -214,6 +213,19 @@ static void parse_special_casing(Core::File& file, UnicodeData& unicode_data)
|
|||
|
||||
unicode_data.special_casing.append(move(casing));
|
||||
}
|
||||
|
||||
quick_sort(unicode_data.special_casing, [](auto const& lhs, auto const& rhs) {
|
||||
if (lhs.code_point != rhs.code_point)
|
||||
return lhs.code_point < rhs.code_point;
|
||||
if (lhs.locale.is_empty() && !rhs.locale.is_empty())
|
||||
return false;
|
||||
if (!lhs.locale.is_empty() && rhs.locale.is_empty())
|
||||
return true;
|
||||
return lhs.locale < rhs.locale;
|
||||
});
|
||||
|
||||
for (u32 i = 0; i < unicode_data.special_casing.size(); ++i)
|
||||
unicode_data.special_casing[i].index = i;
|
||||
}
|
||||
|
||||
static void parse_prop_list(Core::File& file, PropList& prop_list, bool multi_value_property = false)
|
||||
|
|
Loading…
Reference in a new issue