Avoid initializing a struct field.
Steven Schveighoffer
schveiguy at yahoo.com
Mon May 6 12:08:29 PDT 2013
On Mon, 06 May 2013 15:01:42 -0400, jerro <a at a.com> wrote:
> On Monday, 6 May 2013 at 15:15:47 UTC, Steven Schveighoffer wrote:
>> Foo.init must exist, and be filled with *something*. Is it useful to
>> FORCE buffer to not have 0 values? Or is it that you don't care what
>> it has? In the latter, is it terrible that it's 0?
>
> I don't care what it contains, I just want to avoid
> initialization for performance reasons.
The issue is that bar int in there. The compiler does not generate
initialization code that sets up specific members. It basically has an
init value, and it memcpy's that thing onto any uninitialized struct.
If you want performance, initialize the memory (all of it) yourself. You
can't do any worse :)
-Steve
More information about the Digitalmars-d-learn
mailing list