Skip to content

Commit 12a7678

Browse files
committed
Rework std.format
1 parent b869710 commit 12a7678

File tree

1 file changed

+17
-31
lines changed

1 file changed

+17
-31
lines changed

std/format.d

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5425,37 +5425,23 @@ enum Mangle : char
54255425
// routine could go away.
54265426
private TypeInfo primitiveTypeInfo(Mangle m)
54275427
{
5428-
// BUG: should fix this in static this() to avoid double checked locking bug
5429-
__gshared TypeInfo[Mangle] dic;
5430-
if (!dic.length)
5431-
{
5432-
dic = [
5433-
Mangle.Tvoid : typeid(void),
5434-
Mangle.Tbool : typeid(bool),
5435-
Mangle.Tbyte : typeid(byte),
5436-
Mangle.Tubyte : typeid(ubyte),
5437-
Mangle.Tshort : typeid(short),
5438-
Mangle.Tushort : typeid(ushort),
5439-
Mangle.Tint : typeid(int),
5440-
Mangle.Tuint : typeid(uint),
5441-
Mangle.Tlong : typeid(long),
5442-
Mangle.Tulong : typeid(ulong),
5443-
Mangle.Tfloat : typeid(float),
5444-
Mangle.Tdouble : typeid(double),
5445-
Mangle.Treal : typeid(real),
5446-
//Mangle.Tifloat : typeid(ifloat),
5447-
//Mangle.Tidouble : typeid(idouble),
5448-
//Mangle.Tireal : typeid(ireal),
5449-
//Mangle.Tcfloat : typeid(cfloat),
5450-
//Mangle.Tcdouble : typeid(cdouble),
5451-
//Mangle.Tcreal : typeid(creal),
5452-
Mangle.Tchar : typeid(char),
5453-
Mangle.Twchar : typeid(wchar),
5454-
Mangle.Tdchar : typeid(dchar)
5455-
];
5456-
}
5457-
auto p = m in dic;
5458-
return p ? *p : null;
5428+
enum types = [
5429+
"void", "bool", "byte", "ubyte",
5430+
"short", "ushort", "int", "uint", "long", "ulong",
5431+
"float", "double", "real",
5432+
"char", "wchar", "dchar",
5433+
"ifloat", "idouble", "ireal",
5434+
"cfloat", "cdouble", "creal",
5435+
];
5436+
switch (m)
5437+
{
5438+
static foreach (type; types)
5439+
{
5440+
mixin("case Mangle.T"~type~": return typeid("~type~");");
5441+
}
5442+
default:
5443+
return null;
5444+
}
54595445
}
54605446

54615447
private bool needToSwapEndianess(Char)(const ref FormatSpec!Char f)

0 commit comments

Comments
 (0)