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:
Tim Ledbetter
2026-01-08 12:02:18 +00:00
committed by Jelle Raaijmakers
parent 4b556feecf
commit a27d269721
Notes: github-actions[bot] 2026-01-09 09:02:40 +00:00
136 changed files with 663 additions and 557 deletions

View File

@@ -9,24 +9,25 @@
namespace Web::CSS {
String CounterDefinitionsStyleValue::to_string(SerializationMode mode) const
void CounterDefinitionsStyleValue::serialize(StringBuilder& builder, SerializationMode mode) const
{
StringBuilder stb;
bool first = true;
for (auto const& counter_definition : m_counter_definitions) {
if (!stb.is_empty())
stb.append(' ');
if (first)
first = false;
else
builder.append(' ');
if (counter_definition.is_reversed)
stb.appendff("reversed({})", counter_definition.name);
builder.appendff("reversed({})", counter_definition.name);
else
stb.append(counter_definition.name);
builder.append(counter_definition.name);
if (counter_definition.value)
stb.appendff(" {}", counter_definition.value->to_string(mode));
if (counter_definition.value) {
builder.append(' ');
counter_definition.value->serialize(builder, mode);
}
}
return stb.to_string_without_validation();
}
ValueComparingNonnullRefPtr<StyleValue const> CounterDefinitionsStyleValue::absolutized(ComputationContext const& computation_context) const