diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp index 53cc9fb2e1b..5e6962fa677 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp @@ -921,7 +921,7 @@ bool code_point_has_@enum_snake@(u32 code_point, @enum_title@ @enum_snake@) for (auto const& alias : aliases) hashes.set(alias.alias.hash(), alias.alias); - generate_value_from_string_for_dynamic_loading(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes)); + generate_value_from_string(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes)); }; append_prop_search("GeneralCategory"sv, "general_category"sv, "s_general_categories"sv); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp index c33d26f65d3..85ac5440f8e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp @@ -1068,7 +1068,7 @@ Optional get_locale_@enum_snake@_mapping(StringView locale, StringVi for (auto const& alias : aliases) hashes.set(alias.alias.hash(), format_identifier(enum_title, alias.alias)); - generate_value_from_string_for_dynamic_loading(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes)); + generate_value_from_string(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes)); }; auto append_alias_search = [&](StringView enum_snake, auto const& aliases) { @@ -1078,7 +1078,7 @@ Optional get_locale_@enum_snake@_mapping(StringView locale, StringVi for (auto const& alias : aliases) hashes.set(alias.key.hash(), alias.value); - generate_value_from_string_for_dynamic_loading(generator, "resolve_{}_alias"sv, s_string_index_type, enum_snake, move(hashes), "StringView"sv, "s_string_list[{}]"sv); + generate_value_from_string(generator, "resolve_{}_alias"sv, s_string_index_type, enum_snake, move(hashes), "StringView"sv, "s_string_list[{}]"sv); }; append_from_string("Locale"sv, "locale"sv, locale_data.locales.keys(), locale_data.locale_aliases); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index e4b21bb814d..c7ac3e4593b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -304,59 +304,6 @@ void generate_value_from_string(SourceGenerator& generator, StringView method_na generator.set("return_type", return_type.has_value() ? *return_type : value_type); generator.set("size", String::number(hashes.size())); - generator.append(R"~~~( -Optional<@return_type@> @method_name@(StringView key) -{ - constexpr Array, @size@> hash_pairs { { - )~~~"); - - auto hash_keys = hashes.keys(); - quick_sort(hash_keys); - - constexpr size_t max_values_per_row = 10; - size_t values_in_current_row = 0; - - for (auto hash_key : hash_keys) { - if (values_in_current_row++ > 0) - generator.append(" "); - - if constexpr (IsIntegral) - generator.set("value"sv, String::number(hashes.get(hash_key).value())); - else - generator.set("value"sv, String::formatted("{}::{}", value_type, hashes.get(hash_key).value())); - - generator.set("hash"sv, String::number(hash_key)); - generator.append("{ @hash@U, @value@ },"sv); - - if (values_in_current_row == max_values_per_row) { - generator.append("\n "); - values_in_current_row = 0; - } - } - - generator.set("return_statement", String::formatted(return_format, "value->value"sv)); - generator.append(R"~~~( - } }; - - if (auto const* value = binary_search(hash_pairs, key.hash(), nullptr, HashValueComparator<@value_type@> {})) - return @return_statement@; - return {}; -} -)~~~"); -} - -// This is a temporary duplicate of generate_value_from_string() until all generators support dynamic loading. -template -void generate_value_from_string_for_dynamic_loading(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, HashValueMap hashes, Optional return_type = {}, StringView return_format = "{}"sv) -{ - ensure_from_string_types_are_generated(generator); - - generator.set("method_name", String::formatted(method_name_format, value_name)); - generator.set("value_type", value_type); - generator.set("value_name", value_name); - generator.set("return_type", return_type.has_value() ? *return_type : value_type); - generator.set("size", String::number(hashes.size())); - generator.append(R"~~~( Optional<@return_type@> @method_name@(StringView key) asm("unicode_@method_name@"); Optional<@return_type@> @method_name@(StringView key)