On Thu, 2007-08-30 at 13:48 -0400, DJ Delorie wrote: > > I'm not sure what the performance hit might be in removing it, and > > using a test on the object's type. > > From a gcc developer's point of view... > > A C++ method call off a pointer is two loads and an indirect call. > Three opcodes. > > The "type" way is a load, compare, perhaps a switch statement (which > is an indirect jump), and a direct call.
> You take a "big" hit for the compare/switch because it always checks > for out-of-bounds cases, so you end up with a lot of compares and > jumps, which are bad for performance. What if the code "guarantees" type is correct, so we don't need to compare before indexing the vfunc array? > Overall, not much difference, but C++ is a bit faster. > > HOWEVER, from *our* point of view, it's looks like this: > > Adding a new object in C++ means editing one file. > > Adding a new object in C means editing *all* the files that have such > a compare/switch in them. Surely just updating the one vtable? -- Peter Clifton Electrical Engineering Division, Engineering Department, University of Cambridge, 9, JJ Thomson Avenue, Cambridge CB3 0FA Tel: +44 (0)7729 980173 - (No signal in the lab!) _______________________________________________ geda-user mailing list [email protected] http://www.seul.org/cgi-bin/mailman/listinfo/geda-user

