chiark / gitweb /
macro.h: provide a switch-case statement generator for IN_SET
authorDaniel Mack <daniel@zonque.org>
Sun, 10 Jan 2016 17:11:22 +0000 (18:11 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 17 May 2017 13:22:15 +0000 (15:22 +0200)
commit2647e847a11b64dd3757c88afbc1fbb2fb384a6f
tree8bd7f85668b80b126f2cf755660428c069866f9a
parent0800dbe33c6e875b9c11a9baa7c296ecd8640415
macro.h: provide a switch-case statement generator for IN_SET

Rather than walking a list of valid values one-by-one, generate a
switch-case statement for the IN_SET() macro. This allows the compiler to
further optimize its code output, possibly by generating jump tables.
This effectively decreases the binary size slightly.

The implementation is based on macro overloading depending on the number of
arguments. h/t to the following post:

  https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
src/basic/macro.h