Here is a small demostration of the performance increase :

[root@localhost dmd]# time src/dmd -c testSettingArrayLength.d > x 2> x

real    0m0.199s
user    0m0.180s
sys     0m0.017s
[root@localhost dmd]# time src/dmd -c testSettingArrayLength.d -bc-ctfe > x 2> x

real    0m0.072s
user    0m0.050s
sys     0m0.020s

Please note that newCTFE only spends 15 ms inside the evaluation, most time is spent clearing the 2^^24 Bytes of heap-memory to zero.

The sourcode of testSettingArrayLength is
uint[] MakeAndInitArr(uint length)
{
    uint[] arr;
    arr.length = length;

    foreach(i;0 .. length)
    {
        arr[i] = i + 3;
    }
    return arr;
}

static assert(MakeAndInitArr(ushort.max).length == ushort.max);

Reply via email to