skinny delegates

Steven Schveighoffer schveiguy at gmail.com
Thu Aug 2 12:57:02 UTC 2018


On 8/2/18 8:42 AM, Stefan Koch wrote:
> On Monday, 30 July 2018 at 21:02:56 UTC, Steven Schveighoffer wrote:
>> Would it be a valid optimization to have D remove the requirement for 
>> allocation when it can determine that the entire data structure of the 
>> item in question is an rvalue, and would fit into the data pointer 
>> part of the delegate?
> 
> Don't do that. It's valid in simple cases.

Those are the cases I'm referring to.

> As soon as you want to chain delegate pointers it falls apart.

And so, don't do the skinny delegate optimization in that case?

> Also the delegate might require heap allocation to be memory correct.

Does the "might" depend on the caller or on the delegate implementation 
itself? The former would squash this idea.

-Steve


More information about the Digitalmars-d mailing list