Bug 224248 - Wasted vector capacity under RuleFeatureSet::collectFeatures()
Summary: Wasted vector capacity under RuleFeatureSet::collectFeatures()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-06 15:09 PDT by Simon Fraser (smfr)
Modified: 2021-04-07 15:48 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.41 KB, patch)
2021-04-06 15:10 PDT, Simon Fraser (smfr)
hi: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2021-04-06 15:09:03 PDT
Wasted vector capacity under RuleFeatureSet::collectFeatures()
Comment 1 Simon Fraser (smfr) 2021-04-06 15:10:36 PDT
Created attachment 425330 [details]
Patch
Comment 2 Devin Rousso 2021-04-07 09:59:28 PDT
Comment on attachment 425330 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425330&action=review

r=me

> Source/WebCore/style/StyleScopeRuleSets.cpp:253
> +            if (matchElementArray[i]) {

NIT: you could save this as `auto* matchElementItem = matchElementArray[i]` to avoid repeated access

> Source/WebCore/style/StyleScopeRuleSets.cpp:255
> +                invalidationRuleSets->uncheckedAppend({ static_cast<MatchElement>(i), *matchElementArray[i], WTFMove(invalidationSelectorArray[i]) });

NIT: Could this be `matchElementItem.releaseNonNull()` since it's created above?
Comment 3 Antti Koivisto 2021-04-07 10:01:37 PDT
Comment on attachment 425330 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425330&action=review

> Source/WebCore/style/StyleScopeRuleSets.cpp:245
> +        unsigned ruleSetCount = 0;
>          for (unsigned i = 0; i < matchElementArray.size(); ++i) {
>              if (matchElementArray[i])

This loop could now use range-for.
Comment 4 Simon Fraser (smfr) 2021-04-07 15:47:47 PDT
https://trac.webkit.org/changeset/275637/webkit
Comment 5 Radar WebKit Bug Importer 2021-04-07 15:48:52 PDT
<rdar://problem/76369495>