mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +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 ✅
@@ -8,18 +8,24 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String TextUnderlinePositionStyleValue::to_string(SerializationMode) const
|
||||
void TextUnderlinePositionStyleValue::serialize(StringBuilder& builder, SerializationMode) const
|
||||
{
|
||||
if (m_horizontal == TextUnderlinePositionHorizontal::Auto && m_vertical == TextUnderlinePositionVertical::Auto)
|
||||
return "auto"_string;
|
||||
if (m_horizontal == TextUnderlinePositionHorizontal::Auto && m_vertical == TextUnderlinePositionVertical::Auto) {
|
||||
builder.append("auto"sv);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_vertical == TextUnderlinePositionVertical::Auto)
|
||||
return MUST(String::from_utf8(CSS::to_string(m_horizontal)));
|
||||
if (m_vertical == TextUnderlinePositionVertical::Auto) {
|
||||
builder.append(CSS::to_string(m_horizontal));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_horizontal == TextUnderlinePositionHorizontal::Auto)
|
||||
return MUST(String::from_utf8(CSS::to_string(m_vertical)));
|
||||
if (m_horizontal == TextUnderlinePositionHorizontal::Auto) {
|
||||
builder.append(CSS::to_string(m_vertical));
|
||||
return;
|
||||
}
|
||||
|
||||
return MUST(String::formatted("{} {}", CSS::to_string(m_horizontal), CSS::to_string(m_vertical)));
|
||||
builder.appendff("{} {}", CSS::to_string(m_horizontal), CSS::to_string(m_vertical));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user