LibWeb: Don't create identical StyleValueList if absolutization is no-op

This case is actually incredibly common, and this ends up reducing the
memory footprint on https://gymgrossisten.com/ by 2.07 MiB.
This commit is contained in:
Andreas Kling 2025-10-23 22:28:43 +02:00 committed by Andreas Kling
parent 4f684bb4c9
commit a056b26e56
Notes: github-actions[bot] 2025-10-24 06:54:12 +00:00

View file

@ -27,8 +27,17 @@ ValueComparingNonnullRefPtr<StyleValue const> StyleValueList::absolutized(Comput
StyleValueVector absolutized_style_values;
absolutized_style_values.ensure_capacity(m_properties.values.size());
for (auto const& value : m_properties.values)
bool any_absolutized = false;
for (auto const& value : m_properties.values) {
auto absolutized_style_value = value->absolutized(computation_context);
if (absolutized_style_value != value)
any_absolutized = true;
absolutized_style_values.append(value->absolutized(computation_context));
}
if (!any_absolutized)
return *this;
return StyleValueList::create(move(absolutized_style_values), m_properties.separator);
}