summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-13 19:55:08 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-13 19:55:08 +0100
commitc1e6fc67a1f20ada1b4ef881ac1d3bdabf360f34 (patch)
tree24f9bf968bdd25545c3bb30a38db94f4df6cf517 /Userland
parentafc5fade054a4d0e62a81e8678f3fc593133b728 (diff)
downloadserenity-c1e6fc67a1f20ada1b4ef881ac1d3bdabf360f34.zip
LibWeb: Add a Vector::ensure_capacity() in collect_matching_rules()
Avoid some incremental Vector growth by pre-allocating enough capacity to cover the case where every single selector matches an element.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index e69675a1bf..1120c4be44 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -92,6 +92,7 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e
}
Vector<MatchingRule> matching_rules;
+ matching_rules.ensure_capacity(rules_to_run.size());
for (auto const& rule_to_run : rules_to_run) {
auto const& selector = rule_to_run.rule->selectors()[rule_to_run.selector_index];
if (SelectorEngine::matches(selector, element, pseudo_element))