[Issue 3514] opApply should be the first-choice foreach iteration method.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 16 06:21:39 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3514
--- Comment #1 from David Simcha <dsimcha at yahoo.com> 2009-11-16 06:21:38 PST ---
Forgot to mention: Also, when using virtual functions, it may sometimes be
reasonable to define an opApply as an optimization for foreach loops, even if
the range-based foreach has the exact same semantics. For example:
class Foo {
SomeType front() { return _front;}
void popFront() {
// do stuff.
}
bool empty() {
return _empty;
}
}
In this case each iteration will require three virtual function calls, whereas
if opApply were used, the overhead would be reduced to a single delegate call.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list