@@ -444,8 +444,9 @@ ErrorOr<void> generate_implementation_file(JsonObject& properties, JsonObject& l
444444
445445namespace Web::CSS {
446446
447- Optional<PropertyID> property_id_from_camel_case_string(StringView string )
447+ static auto generate_camel_case_property_table( )
448448{
449+ HashMap<StringView, PropertyID, CaseInsensitiveASCIIStringViewTraits> table;
449450)~~~" );
450451
451452 properties.for_each_member ([&](auto & name, auto & value) {
@@ -460,20 +461,24 @@ Optional<PropertyID> property_id_from_camel_case_string(StringView string)
460461 member_generator.set (" name:titlecase" , title_casify (name));
461462 }
462463 member_generator.append (R"~~~(
463- if (string.equals_ignoring_ascii_case("@name:camelcase@"sv))
464- return PropertyID::@name:titlecase@;
464+ table.set("@name:camelcase@"sv, PropertyID::@name:titlecase@);
465465)~~~" );
466466 });
467467
468468 generator.append (R"~~~(
469- return {} ;
469+ return table ;
470470}
471471
472- Optional<PropertyID> property_id_from_string(StringView string)
472+ static HashMap<StringView, PropertyID, CaseInsensitiveASCIIStringViewTraits> const camel_case_properties_table = generate_camel_case_property_table();
473+
474+ Optional<PropertyID> property_id_from_camel_case_string(StringView string)
473475{
474- if (is_a_custom_property_name_string( string))
475- return PropertyID::Custom;
476+ return camel_case_properties_table.get( string);
477+ }
476478
479+ static auto generate_properties_table()
480+ {
481+ HashMap<StringView, PropertyID, CaseInsensitiveASCIIStringViewTraits> table;
477482)~~~" );
478483
479484 properties.for_each_member ([&](auto & name, auto & value) {
@@ -487,13 +492,22 @@ Optional<PropertyID> property_id_from_string(StringView string)
487492 member_generator.set (" name:titlecase" , title_casify (name));
488493 }
489494 member_generator.append (R"~~~(
490- if (string.equals_ignoring_ascii_case("@name@"sv))
491- return PropertyID::@name:titlecase@;
495+ table.set("@name@"sv, PropertyID::@name:titlecase@);
492496)~~~" );
493497 });
494498
495499 generator.append (R"~~~(
496- return {};
500+ return table;
501+ }
502+
503+ static HashMap<StringView, PropertyID, CaseInsensitiveASCIIStringViewTraits> const properties_table = generate_properties_table();
504+
505+ Optional<PropertyID> property_id_from_string(StringView string)
506+ {
507+ if (is_a_custom_property_name_string(string))
508+ return PropertyID::Custom;
509+
510+ return properties_table.get(string);
497511}
498512
499513FlyString const& string_from_property_id(PropertyID property_id) {
0 commit comments