Removing bound checks from a switch statement

Christoph Groth cwg@falma.de
Thu Feb 18 14:44:00 GMT 2010


I do not know how to solve the problem you described, but another way of
speeding up a switch statement might be using the GCC extension "Labels
as Values".

http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

You can retain compatibility to standard C by writing two versions of
the code, one which uses GCC extension and which does not.

Your reaction_t would be an enum for standard C and a void * for gcc.

I am using this trick for my python-like Generator class with iterator
interface (http://vc.falma.de/cfc/tree/cfc/generator.hh)

Would this help?

Christoph



More information about the Gcc-help mailing list