mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
LibWeb: Pass StringBuilder around during StyleValue serialization
Previously, some StyleValues created a large number of intermediate strings during serialization. Passing a StringBUilder into the serialization function allows us to avoid a large number of these unnecessary allocations.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
4b556feecf
commit
a27d269721
Notes:
github-actions[bot]
2026-01-09 09:02:40 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/a27d269721e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7381 Reviewed-by: https://github.com/gmta ✅
@@ -15,9 +15,8 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String ConicGradientStyleValue::to_string(SerializationMode mode) const
|
||||
void ConicGradientStyleValue::serialize(StringBuilder& builder, SerializationMode mode) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (is_repeating())
|
||||
builder.append("repeating-"sv);
|
||||
builder.append("conic-gradient("sv);
|
||||
@@ -25,12 +24,15 @@ String ConicGradientStyleValue::to_string(SerializationMode mode) const
|
||||
bool has_at_position = !m_properties.position->is_center(mode);
|
||||
bool has_color_space = m_properties.interpolation_method.has_value() && m_properties.interpolation_method.value().color_space != InterpolationMethod::default_color_space(m_properties.color_syntax);
|
||||
|
||||
if (has_from_angle)
|
||||
builder.appendff("from {}", m_properties.from_angle->to_string(mode));
|
||||
if (has_from_angle) {
|
||||
builder.append("from "sv);
|
||||
m_properties.from_angle->serialize(builder, mode);
|
||||
}
|
||||
if (has_at_position) {
|
||||
if (has_from_angle)
|
||||
builder.append(' ');
|
||||
builder.appendff("at {}", m_properties.position->to_string(mode));
|
||||
builder.append("at "sv);
|
||||
m_properties.position->serialize(builder, mode);
|
||||
}
|
||||
if (has_color_space) {
|
||||
if (has_from_angle || has_at_position)
|
||||
@@ -41,7 +43,6 @@ String ConicGradientStyleValue::to_string(SerializationMode mode) const
|
||||
builder.append(", "sv);
|
||||
serialize_color_stop_list(builder, m_properties.color_stop_list, mode);
|
||||
builder.append(')');
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void ConicGradientStyleValue::resolve_for_size(Layout::NodeWithStyle const& node, CSSPixelSize size) const
|
||||
|
||||
Reference in New Issue
Block a user