Performance issue in struct initialization

Era Scarecrow via Digitalmars-d digitalmars-d at puremagic.com
Sat May 28 00:08:52 PDT 2016


On Friday, 27 May 2016 at 09:02:17 UTC, Johan Engelen wrote:
> 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!)

  If opEquals and opCmp are overridden then I don't see why voids 
in initialization can't work since how you are comparing it would 
determine equality and not a bitwise compare...


  Hmmm had a longer reply involving changes to a new struct type 
with a few changes...


More information about the Digitalmars-d mailing list