3 ms·
I assume that what the OP meant by Duff's Device is "switch in C is syntactically a goto" rather than the specific loop-unrolling paradigm of Duff's Device itse
by jcranmer 7y ago
I assume that what the OP meant by Duff's Device is "switch in C is syntactically a goto" rather than the specific loop-unrolling paradigm of Duff's Device itself. An example usage I've come across is the bzip2 decompressor:
https://github.com/enthought/bzip2-1.0.6/blob/288acf97a15d558f96c24c89f578b724d6e06b0c/decompress.c#L195 https://github.com/enthought/bzip2-1.0.6/blob/288acf97a15d55...
(note that the case statements are hidden in all of the GET_* macro calls).