Reset class member variables

Nathan Reed nathaniel.reed at gmail.com
Fri Sep 7 15:48:56 PDT 2007


mandel wrote:
> It's nice not to have to sacrifice speed for reliability.

In a garbage collected language like D, allocations are extremely fast, 
potentially several times faster than heap based languages like C/C++.

Using a new instance of the object for each iteration of the loop is 
really what you're doing /conceptually/, anyway...so, I wouldn't worry 
about the allocation performance too much unless you've profiled the app 
and established that it is a bottleneck.

And if that's the case you might want to think about making the object a 
struct (so a value-type, allocated on the stack) anyway.

Thanks,
Nathan Reed



More information about the Digitalmars-d mailing list