Folding similar templates into one

Marco Leise Marco.Leise at gmx.de
Fri Jun 28 05:44:55 PDT 2013


Am Thu, 27 Jun 2013 23:24:48 +0200
schrieb "Meta" <jared771 at gmail.com>:

> I'm not an expert on 
> how DMD works, but could this possibly be done after the native 
> code is generated

I've thought of that as well, but you have to merge templates
at an earlier stage. In case of a compiler such as GCC, the
native code is not even generated in the compiler, but an
external assembler.
That said, DMD does not create duplicate template instances
for the same parameters. I'd assume this includes "string
lambdas". And I'm not sure what you really want to improve for
assertNotThrown. It is a unit testing function and the most
important thing at the moment seems to keep DMD's memory
consumption low, which more compile-time parameters can only
increase.
Another point is that today's best compilers are good at
detecting compile-time constants already and could inline a
function with runtime parameters that are statically known.
I've once let DMD create a switch-case with 81 cases for me
and used a 100% templated function specialized for all these
cases. The result was a major slow-down from all the
compile-time arguments. Run-time arguments are just better!

-- 
Marco



More information about the Digitalmars-d mailing list