Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Adam D. Ruppe
destructionator at gmail.com
Tue Feb 2 13:53:18 UTC 2021
On Tuesday, 2 February 2021 at 13:06:06 UTC, Andrei Alexandrescu
wrote:
> Thought: std.bitmanip.bitfields has some gnarly code that
> generates shifting and masking code for bitfields. It would be
> great to show how that code is vastly improved by the DIP.
Indeed, yikes.
And all that CTFE ~ work... ctfe performs very poorly with ~. So
it would be worth making the interpolation function (idup or
whatever we call it) be sure to avoid that. Doing array copies
into preallocated buffers (buffer[spot .. spot + what.length] =
what[], spot += what.length) is *significantly* faster, you can
double or triple the speed of builds and cut dmd memory use down
by 10x with those simple changes if you use the concated mixins
heavily (my little jni.d did it like this at first and I did
realize such enormous gains there, it was incredible).
That's fairly easy to do with the dip too since 1) the string
literal pieces themselves are all known at compile time and 2)
the length and types of the argument tuple is also known ahead of
time, so you can use a static array to cache their intermediates
(as necessary) while gathering their runtime lengths for the
final copy.
If I can find some time later today I'll see what I can do with
it.
More information about the Digitalmars-d
mailing list