Bug 7120 – Scope Delegates + Delegate Literals

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-12-16T11:23:00Z
Last change time
2012-01-06T10:41:20Z
Keywords
patch, performance
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2011-12-16T11:23:57Z
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(); }
Comment #1 by k.hara.pg — 2012-01-02T01:22:04Z
Comment #2 by bugzilla — 2012-01-06T10:41:20Z