Oops, I've meant to reply to this post:

>
> I didn't intend to imply compile-time construction, just statically
> allocate `ubyte[__traits(classInstanceSize, Ex)]` and lazily emplace
> `Ex` there instead of GC-allocating with `new`. It would be doable with
> `std.typecons.Scoped` if that type wasn't naively anonymized a couple of
> releases ago.

I thought of this for a while and I think lazly dynamic allocation is still better. First things first - there is still lazy initialization both ways.

The only potential gain of statically allocating memory here is on the first exception being thrown, which doesn't gain anything for our prime case of "many exceptions".

Lastly if the said exception is never thrown, static allocation would waste more memory of each thread (TLS). This is especially true for cases where not every thread runs the same code (which is not a small part of the landscape).



--
Dmitry Olshansky

Reply via email to