On Sunday, 16 February 2020 at 12:57:43 UTC, AlphaPurned wrote:
template AA(string[] S)
{
auto _do() { int[string] d; foreach(s; S) d[s] = 0; return d; }
enum AA = _do;
}
if (t in AA!(["a", "and", "mp4", "mp3", "the", "with", "live",
"no", "&", "of", "band"])) continue;
The if statement literally causes a 50x slow down of the code.
(LDC debug, dmd debug takes about 1000 times longer)
template AA(string[] S) {
__gshared int[string] AA;
shared static this() {
int[string] d;
foreach (s; S)
d[s] = 0;
AA = d;
};
}
if (t in AA!(["a", "and", "mp4", "mp3", "the", "with", "live",
"no", "&", "of", "band"])) continue;
This will have the performance you want if you don't care whether
it works in CTFE.