Foreach loops on static arrays error message

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 6 02:05:02 PDT 2017


On Thursday, 6 July 2017 at 08:57:42 UTC, Nemanja Boric wrote:
> On Thursday, 6 July 2017 at 08:49:33 UTC, Stefan Koch wrote:
>> On Thursday, 6 July 2017 at 08:26:42 UTC, Guillaume Chatelet 
>> wrote:
>>>> [...]
>>
>> I'd say this is not often encoutered.
>> One should avoid using a different type then size_t for the 
>> index, as it can have negative performance implications.
>
> Interesting. What would be the example of negative performance 
> implication? I'm guilty of using the int on occasions.

on 64bit a downcast can cause the compiler to emit a cqo 
instruction when the index is used as an index.
it's relatively expensive in some circumstances when it messed up 
predictions.


More information about the Digitalmars-d mailing list