From f63287cd63a9c713b369248f22214fa1345fdf70 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 31 Jul 2021 16:21:01 -0400 Subject: [PATCH] LibUnicode: Initialize manually created Unicode properties inline Using initializer lists directly in the UnicodeData struct definition feels a bit cleaner than invoking HashMap::set in main(). --- .../CodeGenerators/GenerateUnicodeData.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeData.cpp b/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeData.cpp index b85ea1e947..de18f2adba 100644 --- a/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeData.cpp +++ b/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeData.cpp @@ -103,8 +103,17 @@ struct UnicodeData { }; Vector general_category_aliases; - PropList prop_list; + // The Unicode standard defines additional properties (Any, Assigned, ASCII) which are not in + // any UCD file. Assigned is set as the default enum value 0 so "property & Assigned == Assigned" + // is always true. Any is not assigned code points here because this file only parses assigned + // code points, whereas Any will include unassigned code points. + // https://unicode.org/reports/tr18/#General_Category_Property + PropList prop_list { + { "Any"sv, {} }, + { "ASCII"sv, { { 0, 0, 0x7f } } }, + }; Vector prop_aliases; + PropList word_break_prop_list; }; @@ -774,15 +783,6 @@ int main(int argc, char** argv) parse_prop_list(derived_core_prop_file, unicode_data.prop_list); parse_alias_list(prop_alias_file, unicode_data.prop_list, unicode_data.prop_aliases); parse_prop_list(word_break_file, unicode_data.word_break_prop_list); - - // The Unicode standard defines additional properties (Any, Assigned, ASCII) which are not in - // any UCD file. Assigned is set as the default enum value 0 so "property & Assigned == Assigned" - // is always true. Any is not assigned code points here because this file only parses assigned - // code points, whereas Any will include unassigned code points. - // https://unicode.org/reports/tr18/#General_Category_Property - unicode_data.prop_list.set("Any"sv, {}); - unicode_data.prop_list.set("ASCII"sv, { { 0, 0, 0x7f } }); - parse_unicode_data(unicode_data_file, unicode_data); parse_value_alias_list(prop_value_alias_file, "gc"sv, unicode_data.general_categories, unicode_data.general_category_unions, unicode_data.general_category_aliases);