200-600x slower Dlang performance with nested foreach loop

a11e99z black80 at bk.ru
Sun Jan 31 19:33:16 UTC 2021


On Sunday, 31 January 2021 at 16:50:15 UTC, methonash wrote:
> What confuses me, at this point, is this: I originally wrote 
> the D code using foreach in this style:
>
> foreach( i, ref parentString; strings )
>     foreach( j, ref childString; strings[ i + 1 .. $ ] )
>
> Essentially, the value of j printed to stdout should always be 
> larger than the value of i.

j is counted from current begginning: from 0
strings[i+1..$][0] - its right behaviour



More information about the Digitalmars-d-learn mailing list