Skip to content

Commit

Permalink
LibWeb: Give Vector<MatchingRule> some inline capacity in StyleComputer
Browse files Browse the repository at this point in the history
We frequently end up matching hundreds or even thousands of rules. By
giving this vector some inline capacity, we avoid a lot of the
repetitive churn from dynamically growing it all the way from 0
capacity.
  • Loading branch information
awesomekling committed Mar 13, 2024
1 parent 805a82e commit 01b3e4f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e

auto const& rule_cache = rule_cache_for_cascade_origin(cascade_origin);

Vector<MatchingRule> rules_to_run;
Vector<MatchingRule, 512> rules_to_run;
auto add_rules_to_run = [&](Vector<MatchingRule> const& rules) {
rules_to_run.grow_capacity(rules_to_run.size() + rules.size());
if (pseudo_element.has_value()) {
Expand Down

0 comments on commit 01b3e4f

Please sign in to comment.