Performance issue in struct initialization

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 23 07:12:16 PDT 2016


On 4/23/16 10:10 AM, Basile B wrote:
> On Saturday, 23 April 2016 at 13:37:31 UTC, Andrei Alexandrescu wrote:
>> https://issues.dlang.org/show_bug.cgi?id=15951. I showed a few obvious
>> cases, but finding the best code in general is tricky. Ideas? -- Andrei
>
> In the first example you've forget to assign void:
>
> http://d.godbolt.org/#compilers:!((compiler:gdc46,options:'-O3',source:'struct+RCStr(C)%0A%7B%0A++++enum+uint+maxSmall+%3D+64+/+C.sizeof+-+1%3B%0A++++C%5BmaxSmall%5D+small+%3D+void%3B%0A++++ubyte+smallLen+%3D+void%3B%0A%7D%0A%0Aauto+fun()+%7B%0A++RCStr!!char+result+%3D+void%3B%0A++return+result%3B%0A%7D%0A')),filterAsm:(commentOnly:!t,directives:!t,labels:!t),version:3
>
>
> to get the real equivalent to the C++ version.

Thanks. I'm not looking for 100% equivalence as much as defining a 
proper baseline in the C++ version. Asking the user to use "= void" is 
not acceptable.

Andrei



More information about the Digitalmars-d mailing list