[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: interesting links



> > 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?

The only way I know of to do that is to have as many types as there
are values in a given integer-type size.  So, if you have 256 object
types, you can skip a step.

GCC's switch statement logic is pretty smart about minimizing code
execution time, but it still has a lot to do to be compliant with the
C language spec and also never crash.

> > 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?

C, not C++.  Go read the pcb code; it has tables and switch statements
all over the place that check the object type.

If you're using vtables anyway, you might as well put a pointer to the
vtable in the structure and skip all the "type" checking.


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user