mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-03 06:39:07 +00:00
LibWeb: Make CSS::string_from_property_id() return FlyString const&
This avoids costly conversions from StringView to FlyString in CSS parsing and variable expansion.
This commit is contained in:
parent
1cea4e6407
commit
c0e0cb86e1
Notes:
sideshowbarker
2024-07-16 22:11:09 +09:00
Author: https://github.com/awesomekling
Commit: c0e0cb86e1
Pull-request: https://github.com/SerenityOS/serenity/pull/23602
6 changed files with 21 additions and 17 deletions
|
@ -173,7 +173,7 @@ bool is_animatable_property(PropertyID);
|
|||
|
||||
Optional<PropertyID> property_id_from_camel_case_string(StringView);
|
||||
Optional<PropertyID> property_id_from_string(StringView);
|
||||
StringView string_from_property_id(PropertyID);
|
||||
[[nodiscard]] FlyString const& string_from_property_id(PropertyID);
|
||||
bool is_inherited_property(PropertyID);
|
||||
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
|
||||
|
||||
|
@ -401,7 +401,7 @@ Optional<PropertyID> property_id_from_string(StringView string)
|
|||
return {};
|
||||
}
|
||||
|
||||
StringView string_from_property_id(PropertyID property_id) {
|
||||
FlyString const& string_from_property_id(PropertyID property_id) {
|
||||
switch (property_id) {
|
||||
)~~~");
|
||||
|
||||
|
@ -412,14 +412,18 @@ StringView string_from_property_id(PropertyID property_id) {
|
|||
member_generator.set("name", name);
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.append(R"~~~(
|
||||
case PropertyID::@name:titlecase@:
|
||||
return "@name@"sv;
|
||||
case PropertyID::@name:titlecase@: {
|
||||
static FlyString name = "@name@"_fly_string;
|
||||
return name;
|
||||
}
|
||||
)~~~");
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
default:
|
||||
return "(invalid CSS::PropertyID)"sv;
|
||||
default: {
|
||||
static FlyString invalid_property_id_string = "(invalid CSS::PropertyID)"_fly_string;
|
||||
return invalid_property_id_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue