[Webkit-unassigned] [Bug 128644] New: Remove some unintended copies due in ranged for loops
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Feb 11 19:14:42 PST 2014
https://bugs.webkit.org/show_bug.cgi?id=128644
Summary: Remove some unintended copies due in ranged for loops
Product: WebKit
Version: 528+ (Nightly build)
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P2
Component: WebKit Misc.
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: bfulgham at webkit.org
Once I noticed the handful of errors in Bug 128578, I did some more searching and turned up a few more.
Per http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2049.pdf, the ranged iterator syntax:
for( type-specifier-seq simple-declarator : expression )
statement
is syntactically equivalent to
typedef decltype(expression) C;
auto&& rng(expression);
for (auto begin(std::For<C>::begin(rng)), end(std::For<C>::end(rng)); begin != end; ++ begin) {
type-specifier-seq simple-declarator(∗begin);
statement
}
The issue here is that the type of auto (instead of 'auto&' or 'const auto&') causes us to make a copy of each element as we pass through the loop.
When the container is just a set of pointers, it's not much of an issue. But when we have iterate over reference-counted types, strings, or other larger objects we incur unnecessary costs.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list