Hi,
I am working on converting _d_newarray{U,iT,T}
to a template. _d_newarrayU()
calls __setArrayAllocLength()
, which is defined in rt/lifetime.d
. Due to how DRuntime is built, rt/lifetime.d
cannot be imported into core/lifetime.d
(or core/internal/lifetime.d
).
To circumvent this, I also moved __setArrayAllocLength()
along with other functions in that call stack such as __arrayStart()
to core/lifetime.d
. To avoid some linker errors caused by the fact that core/lifetime.d
is not compiled into the libdruntime.a
as it's only meant to contain templates, I converted __setArrayAllocLength()
and the other functions to "empty" templates (with no template arguments) just to see if they work. They do.
So my approach now is to convert these new templates to "real" templates, that use their template argument instead of TypeInfo
. This will help use TypeInfo
less (and hopefully at some point not use it at all in the runtime) but may lead to a lot of template bloating. To reduce this, it's worth noting that __setArrayAllocLength()
only uses TypeInfo
to place it at the end of the allocated array. Therefore, the template implementation can be split into a small template (that only handles this part) and a larger non-template function that does everything else (which is common for all types).
Do you agree with this approach or do you have other suggestions?
Thanks,
Teo