On Thursday, 5 July 2018 at 12:50:18 UTC, Ivan Kazmenko wrote:
Is there any better way? To prevent introducing bugs when micro-optimizing, I'd like the loop body to remain as unchanged as it can be.

foreach(j, ref piece; cast(int[4][]) a)
{   auto pieceI = j * 4;
    static foreach(i; 0 .. piece.length) piece[i] = pieceI + i;
}

Can probably be made even better by designing some template helper.

Reply via email to