Initialization of std.typecons.RefCounted objects

Matthias Walter xammy at xammy.info
Thu Jul 19 03:39:32 PDT 2012


On 07/19/2012 10:14 AM, Christophe Travert wrote:
> "monarch_dodra" , dans le message (digitalmars.D:172700), a écrit :
>> I think it would be better to "initialize on copy", rather than 
>> default initialize. There are too many cases an empty array is 
>> created, then initialized on the next line, or passed to 
>> something else that does the initialization proper.
> 
> Not default-initializing Array has a cost for every legitimate use of an 
> Array. I think people use Array more often than they create 
> uninitialized ones that are not going to be used before an other Array 
> instance is assigned to them, so Array would be more efficient if it was 
> default initialized and never check it is initialized again. But that's 
> just speculation.

I agree here. Additionally my question: Is it possible (at the moment)
to really do "initialize on copy"? As far as I see it, the only way to
interact here is to implement 'this(this)' which is called after
bit-copying and hence cannot access the source of the copy process.





More information about the Digitalmars-d mailing list