On Fri, Nov 20, 2009 at 6:00 PM, Mark Mentovai <[email protected]> wrote:
> James Robinson wrote: > > What's the benefit of omitting the virtual destructor? > > The benefit is that the destructor stays out of the vtable, which will > potentially reduce the vtable size and save a layer of indirection. I > don't consider either of these advantages compelling. I agree that > it's overshadowed by the bugs that occur when a caller expects virtual > destructor semantics but they're not available. > In the cases where the type is statically known, I have seen GCC make the destructor a static call (which can be inlined), so in the cases where there isn't potentially a problem there is no indirection and therefore zero runtime overhead. If there is potentially a problem, then I would argue against the optimization that is usually ok in favor of known correct code. One vtbl entry per such class seems trivially insignificant. -- John A. Tamplin Software Engineer (GWT), Google -- Chromium Developers mailing list: [email protected] View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev
