std.variant is so incredibly slow! It's practically unusable for anything, which requires even a tiny bit of performance.
void on()
{
auto var = Variant(5);
int i = var.get!int;
}
void off()
{
auto var = 5;
int i = var;
}
void main()
{
writeln(benchmark!(on, off)(100000));
}
The result is:
[TickDuration(25094), TickDuration(98)]
There are tons of cases, where a simple typeless data storage is necessary. No type information, no type checking - just a low-level storage, upon which Variant and other dynamic-type constructs can be built.
I want to ask the community: what's the best way to store any variable in a typeless storage, so that one could store any variable in that storage and get a reference to that variable given its static type with no type checking and minimal overhead compared to a statically typed storage and with type-safe storage (postblits, garbage collection...)?
--
Bye,
Gor Gyolchanyan.