Sunday, March 31, 2013

C: Computed gotos vs. switch statement

A fairly new feature of some C compilers is the "computed goto", which is around 20% faster than a traditional switch-statement.

http://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables/

That's a great description, with examples, benchmarks, and an explanation of why it's faster. I'm recording that link here because I often forget the *name* of this thing. If you don't know what you're looking for, it's hard to find.

No comments:

Post a Comment