1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

LibWeb: Avoid unnecessary copies in StyleInvalidator

This commit is contained in:
Ben Wiederhake 2021-12-24 21:38:33 +01:00 committed by Andreas Kling
parent 0c365fdfd3
commit 3013e74d3a

View file

@ -29,12 +29,12 @@ StyleInvalidator::~StyleInvalidator()
return;
auto& style_computer = m_document.style_computer();
m_document.for_each_in_inclusive_subtree_of_type<DOM::Element>([&](auto& element) {
auto maybe_matching_rules_before = m_elements_and_matching_rules_before.get(&element);
if (!maybe_matching_rules_before.has_value()) {
auto matching_rules_before_iter = m_elements_and_matching_rules_before.find(&element);
if (matching_rules_before_iter == m_elements_and_matching_rules_before.end()) {
element.set_needs_style_update(true);
return IterationDecision::Continue;
}
auto& matching_rules_before = maybe_matching_rules_before.value();
auto& matching_rules_before = matching_rules_before_iter->value;
auto matching_rules_after = style_computer.collect_matching_rules(element);
if (matching_rules_before.size() != matching_rules_after.size()) {
element.set_needs_style_update(true);