Templates do maybe not need to be that slow (no promises)
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 9 00:56:04 PDT 2016
Hi Guys,
I keep this short.
There seems to be much more headroom then I had thought.
The Idea is pretty simple.
Consider :
int fn(int padLength)(int a, int b, int c)
{
/**
very long function body 1000+ lines
*/
return result * padLength;
}
This will produce roughly the same code for every instaniation
expect for one imul at the end.
This problem is known as template bloat.
There is a direct linear relationship between the generated code
and the template body.
So If the range of change inside the template body can be linked
to the changed range in the binray and we link this to the
template parameters we can produce a pure function that can give
us the change in the binary code when provided with the template
parameters.
And the need to rerun the instanciation and code-gen is reduced
to just the changed sections.
I am not yet sure if this is viable to implement.
More information about the Digitalmars-d
mailing list