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.
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.