ソースを参照

LibWeb: Use unchecked_append in StyleComputer::collect_matching_rules()

We already grow the "rules to run" vector before appending to it, so we
can actually use unchecked_append() here and avoid the "needs to grow"
checks every time we append to it.

This takes appending from 3% to <1% when loading our GitHub repo.
Andreas Kling 1 年間 前
コミット
a378303629
1 ファイル変更2 行追加2 行削除
  1. 2 2
      Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

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

@@ -315,12 +315,12 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e
         if (pseudo_element.has_value()) {
             for (auto const& rule : rules) {
                 if (rule.contains_pseudo_element && filter_namespace_rule(element, rule))
-                    rules_to_run.append(rule);
+                    rules_to_run.unchecked_append(rule);
             }
         } else {
             for (auto const& rule : rules) {
                 if (filter_namespace_rule(element, rule))
-                    rules_to_run.append(rule);
+                    rules_to_run.unchecked_append(rule);
             }
         }
     };