ソースを参照

LibWeb: Give Vector<MatchingRule> some inline capacity in StyleComputer

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.
Andreas Kling 1 年間 前
コミット
c6e37d0c44
1 ファイル変更1 行追加1 行削除
  1. 1 1
      Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

+ 1 - 1
Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

@@ -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()) {