Just playing with compiler explorer to see assembly line count.

rikki cattermole rikki at cattermole.co.nz
Tue Oct 3 13:53:38 UTC 2017


Be warned, x86 cpu's today are not like they were 10 years ago. A good 
portion of a symbol could be full of nop's and it could end up being 
faster than the one without them.

Next, compare against ldc, not gdc primarily. Its better maintained and 
ugh more inline with dmd (its a bit of a mess, lets not go there). Of 
course nothing wrong with doing both.

std.container.* is basically dead. We need to replace it. We are 
currently waiting on std.experimental.allocators before going much more 
further (also a lot of other no-gc stuff).

Compare (on https://d.godbolt.org/ with "ldc -O3" and "gdc -O3"):
---
auto test1(int[] arr, int cmp)
{
     int[] r;
     foreach(v ; arr)
       if(v == cmp)r~=v;
     return r;
}

import std.container.array;
auto test2(ref Array!int arr, int cmp)
{
     Array!int r;
     foreach(v ; arr)
       if(v == cmp)r.insert(v);
     return r;
}
---


More information about the Digitalmars-d mailing list