jai-like CTFE string formating
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 12 04:47:10 PDT 2017
Hi Guys,
I've just implemented a subset of the std.format functionality.
In the same style that Johnathan Blow uses for JAI.
It's about 10x faster then using std.format and uses much less
memory :)
the follwing code takes over 250 ms to compile :
{
import std.format;
pragma(msg, format("Hello %s %s %s %s %s %s %s %s %s", " I ",
"just", " have", " to", " concat", " a lot", " of", " strings
...", 9));
}
Whereas the following alternative takes 20 ms :
{
import ctfe_utils;
pragma(msg, format_jai("Hello % % % % % % % % %", " I ", "
just", " have" , " to", " concat", " a lot", " of", " strings
...", 9));
}
see for yourself:
https://www.youtube.com/watch?v=T0BJxdt61RY
More information about the Digitalmars-d
mailing list