mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +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 ✅
@@ -17,12 +17,13 @@ ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> GridTemplateAreaSt
|
||||
return adopt_ref(*new (nothrow) GridTemplateAreaStyleValue(grid_template_area));
|
||||
}
|
||||
|
||||
String GridTemplateAreaStyleValue::to_string(SerializationMode) const
|
||||
void GridTemplateAreaStyleValue::serialize(StringBuilder& builder, SerializationMode) const
|
||||
{
|
||||
if (m_grid_template_area.is_empty())
|
||||
return "none"_string;
|
||||
if (m_grid_template_area.is_empty()) {
|
||||
builder.append("none"sv);
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
for (size_t y = 0; y < m_grid_template_area.size(); ++y) {
|
||||
if (y != 0)
|
||||
builder.append(' ');
|
||||
@@ -34,7 +35,6 @@ String GridTemplateAreaStyleValue::to_string(SerializationMode) const
|
||||
}
|
||||
serialize_a_string(builder, row_builder.string_view());
|
||||
}
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user