On Monday, 8 February 2016 at 13:01:44 UTC, Steven Schveighoffer wrote:
On 2/7/16 12:18 AM, Steven Schveighoffer wrote:
I have a library where I was using very many voldemort types a la
std.range.


[snip]

Is there a better way we should be doing this? I'm wondering if
voldemort types are really worth it. They offer a lot of convenience, and are much DRYer than separate private template types. But the bloat
cost is not really worth the convenience IMO.

I modified all my voldemort-returning functions to return module-level types.

One of my example programs (compiled optimized/inline) went from 10MB to 1MB. The other example program went from 2.1MB to 900k.

-Steve

Just to be sure, you replaced something like this:

auto myFunc(int x){
   struct MyStruct{ int a; }
   return MyStruct(x);
}

with?

private struct MyStruct{ int a; }
auto myFunc(int x){
    return MyStruct(x);
}

Reply via email to