[Issue 7120] New: Scope Delegates + Delegate Literals
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 16 11:23:58 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7120
Summary: Scope Delegates + Delegate Literals
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: performance
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dsimcha at yahoo.com
--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2011-12-16 11:23:57 PST ---
The following code apparently heap-allocates a closure even though doNothing()
takes a scope delegate. This happens when doNothing() is passed a delegate
literal. When it's passed the address of a named inner function, no heap
allocation takes place.
import core.memory;
void main() {
GC.disable();
foreach(j; 0..1_000_000_000) {
doIt();
}
}
void doIt() {
int i;
doNothing(() { i++; });
}
void doNothing(scope void delegate() dg) {
dg();
}
--
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