Implementing and optimizing a simple graph metric

Joseph Rushton Wakeling joseph.wakeling at
Thu Sep 26 14:09:30 PDT 2013

On Thursday, 26 September 2013 at 20:56:39 UTC, bearophile wrote:
> Joseph Rushton Wakeling:
>> I have not found this -- using minimallyInitializedArray for 
>> the arrays of built-in types is slower than if I use 
>> uninitializedArray.
> Then minimallyInitializedArray should be improved :-)

It's odd, because the two actually use the same underlying 
function, with minimallyInitializedArray potentially triggering 
this section:

     else static if(minimallyInitialized && hasIndirections!E)
         ret[] = E.init;

... but if E is (say) an int, or a size_t, or any other built-in 
type, this should not be triggered -- right?

So it's bizarre that there is a performance difference here.

Incidentally, this was why I felt safe using uninitializedArray 
for arrays of e.g. long, size_t, etc., because the only 
difference at the end of the function could be whether the values 
contained in the array have been set or not.  As I do ensure that 
any array entry used also has its value set, it should be OK.

More information about the Digitalmars-d-announce mailing list