Performance issue in struct initialization

Johan Engelen via Digitalmars-d digitalmars-d at puremagic.com
Fri May 27 02:02:17 PDT 2016


> https://issues.dlang.org/show_bug.cgi?id=15951
> https://issues.dlang.org/show_bug.cgi?id=11817
> https://issues.dlang.org/show_bug.cgi?id=11331

What I gather from the discussions is that the current spec says 
that:

```
struct S {
   char[100] arr = void;
}

S a;
S b;
assert(a == b);
```

That language guarantee prevents optimization of the 
initialization (in this case, the optimized result would be no 
initialization at all).
So a breaking language spec change would be needed. Is this 
pursued by anyone?
Perhaps only relax the spec when the struct S overrides opEquals ?

(Once the optimization is allowed, I think it will be a fun 
project for me to implement it in LDC. But please keep the 
discussion clean by not discussing how a compiler should make use 
of this language change, how to implement it, etc. Thanks!)

cheers,
   Johan



More information about the Digitalmars-d mailing list