Loop optimization

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Thu May 13 23:33:54 PDT 2010


On Fri, 14 May 2010 06:31:29 +0000, Lars T. Kyllingstad wrote:
>     void main ()
>     {
>         double[] foo = new double [cast(int)1e6]; double[] slice1 =
>         foo[0 .. 999_998];
>         double[] slice2 = foo[1 .. 999_999];
> 
>         for (int i=0;i<1e3;i++)
>         {
>             // BAD, BAD, BAD.  DON'T DO THIS even though // it's pretty
>             awesome:
>             slice1[] += slice2[];
>         }
>     }

Hmm.. something very strange is going on with the line breaking here.

-Lars


More information about the Digitalmars-d-learn mailing list