| Summary: | Correct some uses of 'auto' | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Brent Fulgham <bfulgham> | ||||
| Component: | WebCore Misc. | Assignee: | Brent Fulgham <bfulgham> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | aboxhall, andersca, apinheiro, bfulgham, cfleizach, cmarcelo, commit-queue, darin, dmazzoni, esprehn+autocc, glenn, gyuyoung.kim, jamesr, jdiggs, jfernandez, kangil.han, kondapallykalyan, luiz, macpherson, mario, menard, rego, samuel_white, svillar, tonikitoo | ||||
| Priority: | P2 | ||||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
Created attachment 223809 [details]
Patch
Comment on attachment 223809 [details] Patch Clearing flags on attachment: 223809 Committed r163882: <http://trac.webkit.org/changeset/163882> All reviewed patches have been landed. Closing bug. 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. |
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.