Bug 150091 - Avoid useless copies in range-loops that are using 'auto'
Summary: Avoid useless copies in range-loops that are using 'auto'
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-13 10:45 PDT by Chris Dumez
Modified: 2015-10-13 12:16 PDT (History)
4 users (show)

See Also:


Attachments
Patch (58.09 KB, patch)
2015-10-13 10:52 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (57.75 KB, patch)
2015-10-13 11:43 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-10-13 10:45:14 PDT
Avoid useless copies in range-loops that are using 'auto'. Also use 'auto*' instead of 'auto' when range values are pointers for clarity.
Comment 1 Chris Dumez 2015-10-13 10:52:56 PDT
Created attachment 262992 [details]
Patch
Comment 2 Darin Adler 2015-10-13 11:35:43 PDT
Comment on attachment 262992 [details]
Patch

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

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:142
> -    for (auto track : stream.tracks()) {
> +    for (auto& track : stream.tracks()) {
>          m_MediaStreamPrivate->addTrack(WTF::move(track));

This one changes semantics, not just efficiency. Moving from a reference is different from moving from a copy. Hope that’s OK. I didn’t have time just now to look at the tracks() function to make sure it’s harmless.

> Source/WebKit2/UIProcess/WebProcessProxy.cpp:482
> +    for (auto& iter : m_pageURLRetainCountMap) {

The name iter is so lame.
Comment 3 Chris Dumez 2015-10-13 11:43:09 PDT
Created attachment 263002 [details]
Patch
Comment 4 WebKit Commit Bot 2015-10-13 12:16:32 PDT
Comment on attachment 263002 [details]
Patch

Clearing flags on attachment: 263002

Committed r191002: <http://trac.webkit.org/changeset/191002>
Comment 5 WebKit Commit Bot 2015-10-13 12:16:38 PDT
All reviewed patches have been landed.  Closing bug.