Title: [275637] trunk/Source/WebCore
- Revision
- 275637
- Author
- [email protected]
- Date
- 2021-04-07 15:36:11 -0700 (Wed, 07 Apr 2021)
Log Message
Wasted vector capacity under RuleFeatureSet::collectFeatures()
https://bugs.webkit.org/show_bug.cgi?id=224248
Reviewed by Devin Rousso.
The RuleSets constructed ensureInvalidationRuleSets() were never shrunk,
causing up to 500KB of wasted vector capacity on youtube.com.
This change calls shrinkToFit() on the RuleSets, and on the InvalidationRuleSet
vector.
* style/StyleScopeRuleSets.cpp:
(WebCore::Style::ensureInvalidationRuleSets):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (275636 => 275637)
--- trunk/Source/WebCore/ChangeLog 2021-04-07 22:32:29 UTC (rev 275636)
+++ trunk/Source/WebCore/ChangeLog 2021-04-07 22:36:11 UTC (rev 275637)
@@ -1,5 +1,21 @@
2021-04-07 Simon Fraser <[email protected]>
+ Wasted vector capacity under RuleFeatureSet::collectFeatures()
+ https://bugs.webkit.org/show_bug.cgi?id=224248
+
+ Reviewed by Devin Rousso.
+
+ The RuleSets constructed ensureInvalidationRuleSets() were never shrunk,
+ causing up to 500KB of wasted vector capacity on youtube.com.
+
+ This change calls shrinkToFit() on the RuleSets, and on the InvalidationRuleSet
+ vector.
+
+ * style/StyleScopeRuleSets.cpp:
+ (WebCore::Style::ensureInvalidationRuleSets):
+
+2021-04-07 Simon Fraser <[email protected]>
+
Reduce Vector<> wasted capacity in some RuleSet code
https://bugs.webkit.org/show_bug.cgi?id=224160
Modified: trunk/Source/WebCore/style/StyleScopeRuleSets.cpp (275636 => 275637)
--- trunk/Source/WebCore/style/StyleScopeRuleSets.cpp 2021-04-07 22:32:29 UTC (rev 275636)
+++ trunk/Source/WebCore/style/StyleScopeRuleSets.cpp 2021-04-07 22:36:11 UTC (rev 275637)
@@ -239,10 +239,21 @@
invalidationSelectorArray[arrayIndex].append(feature.invalidationSelector);
}
}
+
+ unsigned ruleSetCount = 0;
+ for (const auto& item : matchElementArray) {
+ if (item)
+ ++ruleSetCount;
+ }
+
auto invalidationRuleSets = makeUnique<Vector<InvalidationRuleSet>>();
+ invalidationRuleSets->reserveInitialCapacity(ruleSetCount);
+
for (unsigned i = 0; i < matchElementArray.size(); ++i) {
- if (matchElementArray[i])
- invalidationRuleSets->append({ static_cast<MatchElement>(i), *matchElementArray[i], WTFMove(invalidationSelectorArray[i]) });
+ if (matchElementArray[i]) {
+ matchElementArray[i]->shrinkToFit();
+ invalidationRuleSets->uncheckedAppend({ static_cast<MatchElement>(i), matchElementArray[i].releaseNonNull(), WTFMove(invalidationSelectorArray[i]) });
+ }
}
return invalidationRuleSets;
}).iterator->value.get();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes