Removing bound checks from a switch statement

Christoph Groth
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".

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 (

Would this help?


More information about the Gcc-help mailing list