Skip to content

Commit a056b26

Browse files
committed
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.
1 parent 4f684bb commit a056b26

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Libraries/LibWeb/CSS/StyleValues/StyleValueList.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,17 @@ ValueComparingNonnullRefPtr<StyleValue const> StyleValueList::absolutized(Comput
2727
StyleValueVector absolutized_style_values;
2828
absolutized_style_values.ensure_capacity(m_properties.values.size());
2929

30-
for (auto const& value : m_properties.values)
30+
bool any_absolutized = false;
31+
32+
for (auto const& value : m_properties.values) {
33+
auto absolutized_style_value = value->absolutized(computation_context);
34+
if (absolutized_style_value != value)
35+
any_absolutized = true;
3136
absolutized_style_values.append(value->absolutized(computation_context));
37+
}
38+
39+
if (!any_absolutized)
40+
return *this;
3241

3342
return StyleValueList::create(move(absolutized_style_values), m_properties.separator);
3443
}

0 commit comments

Comments
 (0)