Method template optimization that works in C++, but not very well D
Vladimir
v.s.zverev at gmail.com
Fri Feb 21 09:39:11 PST 2014
On Thursday, 20 February 2014 at 22:36:58 UTC, Ali Çehreli wrote:
> int proccessRowTemplate(size_t optionVariant)(in Row table)
> {
> int sum = 0;
> foreach(size_t i; StaticRange!(Row.numberField))
> {
> static if (optionVariant & 1<<i)
> {
> sum += table.Fields[i] ^^ 2 - i;
> }
> }
> return sum;
> }
This version of the program looks more graceful than mine, and
works faster. My example in github is updated.
>
> Results on my system after that change:...
> Simple processing: 35 ms
> ...
> Template processing: 15 ms
>
I got same result in my system for dmd. It is good.
But for ldc and gdc the result is almost unchanged. May be there
are more ideas why this optimization does not help in cases gdc
and ldc? I looked at the llvm-ir code my example ... At first
glance, there is exactly what it should be.
In any case, thank you
More information about the Digitalmars-d-learn
mailing list