Struct default constructor - need some kind of solution for C++ interop

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 8 16:07:28 PDT 2016


On 9/8/2016 4:26 AM, Ethan Watson wrote:
> On Thursday, 8 September 2016 at 11:18:12 UTC, Walter Bright wrote:
>> The thing is, the 'destroy()' function is going to swamp any extra clock
>> cycle, as will a virtual lookup and dereference.
>
> Assume destroy() is a more trivial function then. The point is that if you put
> more than two branches in a 64-byte cacheline on that processor, things get
> significantly slower and the loop iteration itself becomes a hotspot.

Putting a destructor call in a tight loop is probably not a good pattern. Hoist 
it out of the loop.


> Being D though. Destructors can be contracted, yeah? Because the way we operate
> is that we compile out all those validation checks for a retail release and
> assume everything works. Checking for the validity of the pointer in an in block
> would be perfect for that.

Sounds good!


More information about the Digitalmars-d mailing list