RESOLVED FIXED 128578
Correct some uses of 'auto'
https://bugs.webkit.org/show_bug.cgi?id=128578
Summary Correct some uses of 'auto'
Brent Fulgham
Reported 2014-02-10 21:19:27 PST
I recently noticed a number of places where we were using the following idiom: for (auto rect : dirtyRects) { // ... do some stuff ... } The C++11 standard indicates that this produces something along the lines of: "auto elem = *__begin;" which copies each element. We should prefer to use "for (const auto& ..." wherever possible, or "for (auto&" in cases where we need to modify the elements.
Attachments
Patch (14.73 KB, patch)
2014-02-10 22:16 PST, Brent Fulgham
no flags
Brent Fulgham
Comment 1 2014-02-10 22:16:47 PST
WebKit Commit Bot
Comment 2 2014-02-11 09:31:06 PST
Comment on attachment 223809 [details] Patch Clearing flags on attachment: 223809 Committed r163882: <http://trac.webkit.org/changeset/163882>
WebKit Commit Bot
Comment 3 2014-02-11 09:31:10 PST
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 4 2014-02-11 12:12:33 PST
I wholeheartedly agree that auto is not good when this churn happens. And I’m really glad you fixed this! I don’t really prefer const auto& over auto&, though. I can’t think of any harm that comes from using auto&. If we only have const access to the collection, then the const works automatically. If we have non-const access, then it doesn’t seem worth the extra word just to narrow the access for the body of the loop.
Note You need to log in before you can comment on or make changes to this bug.