On Sunday, 9 July 2023 at 14:49:39 UTC, Steven Schveighoffer
wrote:
This is probably a bug somewhere, 4 seconds is too much. A
reduced test case would be helpful.
But I wanted to note, inside a struct template, the template
name (by itself) is equivalent to the current instantiation. So
just returning `BindingTempl` would be equivalent, and might
not trigger this problem.
See if that helps.
-Steve
Thank you for letting me know about being able to use
`BindingTempl`, I had no idea! Unfortunately it doesn't mitigate
the compile times, though.
I forgot to mention, it only happens when specifying `-O` with
DMD. LDC and GDC compile the same thing almost instantly.
Boiling it down to a simple test is tough. If you remove a lot of
components the struct template depends on then the compile time
is too fast for anything to be noticeable. I think the issue is
some kind of snowball-effect.
If anyone wants to try to reproduce this issue:
1. Download [this exact
commit](https://github.com/ichordev/bindbc-imgui/tree/65d02d68e4188250c948147a04a5820de3479a44) of the WIP BindBC-ImGui repo. (the newer commits won't compile)
2. Edit dub.selections.json to change `"bindbc-common"`'s version
to `"0.0.6"`.
3. Run:
```
dmd -extern-std=c++11 -lib -O -version=BindImGui_Static -Isource/
-I~/.dub/packages/bindbc-common/0.0.6/bindbc-common/source/
source/bindbc/imgui/config.d source/bindbc/imgui/package.d
source/imgui/impl.d source/imgui/package.d -v
```
4. Now, remove `-O` from the dmd command. Blink and you'll miss
it compiling!