Bug 173748 - Avoid moving the same vector multiple times
Summary: Avoid moving the same vector multiple times
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-06-22 16:58 PDT by Brent Fulgham
Modified: 2017-06-23 11:05 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.89 KB, patch)
2017-06-22 17:04 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (7.86 KB, patch)
2017-06-23 10:15 PDT, Brent Fulgham
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2017-06-22 16:58:56 PDT
Code inspection revealed that a Vector of String was being WTFMove'd multiple times in a loop. Don't do that!
Comment 1 Radar WebKit Bug Importer 2017-06-22 16:59:20 PDT
<rdar://problem/32936804>
Comment 2 Brent Fulgham 2017-06-22 17:04:21 PDT
Created attachment 313675 [details]
Patch
Comment 3 Chris Dumez 2017-06-22 18:38:38 PDT
Comment on attachment 313675 [details]
Patch

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

> Source/WebKit2/UIProcess/WebProcessProxy.cpp:261
> +        Vector<String> topDomains = topPrivatelyControlledDomains;

Brady or Darin may have a better idea. Personally, I would pass the Vector as a const Vector& until it actually needs copying (inside WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()).
Comment 4 Brent Fulgham 2017-06-23 09:34:38 PDT
Comment on attachment 313675 [details]
Patch

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

>> Source/WebKit2/UIProcess/WebProcessProxy.cpp:261
>> +        Vector<String> topDomains = topPrivatelyControlledDomains;
> 
> Brady or Darin may have a better idea. Personally, I would pass the Vector as a const Vector& until it actually needs copying (inside WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()).

OK. That will make the patch bigger, but might avoid a number of copies if the lowest level of the 'fetch' algorithm skip this work for some reason. I'll try that.
Comment 5 Brent Fulgham 2017-06-23 10:15:02 PDT
Created attachment 313726 [details]
Patch
Comment 6 Chris Dumez 2017-06-23 10:34:55 PDT
Comment on attachment 313726 [details]
Patch

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

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:516
> +            for (const auto& topPrivatelyControlledDomain : topPrivatelyControlledDomains) {

I think we prefer just "auto&" without const.
Comment 7 Brent Fulgham 2017-06-23 11:05:24 PDT
Committed r218753: <http://trac.webkit.org/changeset/218753>