mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +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 ✅
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user