March 24, 2022

Sometimes, simple looking template interfaces and implementations have a hidden cost in increased compile times. In his latest blog post, Max Haughton shows some of those cases, explains what causes the increase, and shows how to rewrite your templates when possible to alleviate the problem.

The blog:
https://dlang.org/blog/2022/03/24/reducing-template-compile-times/

Reddit:
https://www.reddit.com/r/programming/comments/tmewno/reducing_template_compile_times_in_dlang/

March 27, 2022
On 3/24/22 07:54, Mike Parker wrote:

> The blog:
> https://dlang.org/blog/2022/03/24/reducing-template-compile-times/

There is an opportunity for a minor optimization where the following code is introduced in the article.

To reduce code compiled for the non-unittest binary, I sometimes define types and import declarations needed only by unittests, inside version(unittest) blocks:

version (unittest) {        // <-- ADDED

import some_unittest_utils; // <-- Added example

struct JustInt
{
  int x;
}

}                           // <-- ADDED

static foreach(_; 0..5)
{
  unittest
  {
    JustInt value;
    value.send;
  }
}

Ali