std.string.translate using initializing twice?

simendsjo simen.endsjo at pandavre.com
Mon Aug 9 18:03:48 PDT 2010


On 10.08.2010 02:59, Jonathan M Davis wrote:
> On Monday, August 09, 2010 17:45:07 simendsjo wrote:
>> translate does this:
>>       bool[256] deltab; // this would make all values of deltab false as
>> bool.init == false, right?
>>
>>       deltab[] = false;
>>
>> Isn't this just initializing all values of deltab to false twice..?
>
> I believe that you are correct and that the array is getting set twice.
>
>>   [snip]...
>
> I confess that it's entirely irrational on my part given that D is smart enough
> that a post-increment where the temporary is not used should be just as efficient
> as a pre-increment (even in the face of operator overloading - unlike C++), but
> it always makes me cringe to see post-increments where a pre-increment would
> do...
>
> - Jonathan M Davis

Yeah. Don't remember when, don't remember where, but I too have read 
that preincrement is faster (PS: I don't know any assembler!).

As long as I don't use it in an expression, I always use post-increment 
as it shouldn't make a difference.


More information about the Digitalmars-d-learn mailing list