From 5e54cf7db418797039816e37fc636e2f29926760 Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Fri, 15 Dec 2017 13:23:49 -0500 Subject: [PATCH] Dramatically faster to compile Tuple --- std/typecons.d | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/std/typecons.d b/std/typecons.d index 0402d7c562a..9623b97fda6 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -535,16 +535,15 @@ if (distinctFieldNames!(Specs)) string injectNamedFields() { string decl = ""; - foreach (i, name; staticMap!(extractName, fieldSpecs)) - { - import std.format : format; - - decl ~= format("alias _%s = Identity!(field[%s]);", i, i); - if (name.length != 0) + static foreach (i, val; fieldSpecs) + {{ + immutable si = i.stringof; + decl ~= "alias _" ~ si ~ " = Identity!(field[" ~ si ~ "]);"; + if (val.name.length != 0) { - decl ~= format("alias %s = _%s;", name, i); + decl ~= "alias " ~ val.name ~ " = _" ~ si ~ ";"; } - } + }} return decl; }