On Thursday, 3 November 2016 at 03:43:06 UTC, Vladimir Panteleev wrote:
For each function that is only called during compilation (e.g. for code generation), at the top add:

        if (!__ctfe)
                return;

That's it. For one project, this brought compilation time (with optimizations) from over an hour down to seconds!

As it turns out, DMD will codegen all functions, even templated ones when they're instantiated, whether they're called by something or not.

Sounds like an issue. Although, I almost think a @noctfe tag which would refuse to compile/use code during CTFE, or in effect add that line at the beginning to functions invisibly.

Obviously having functions only voluntarily used for CTFE would be a pain. having a section Opt Out after a certain point seems more useful, and would require far less work for the programmers.

Reply via email to