Archives
All Posts Tagged
Tag: ‘tom duff’

Duff’s device

The famous “Duff’s device” in C makes use of the fact that a case statement is still legal within a sub-block of its matching switch statement. Tom Duff used this for an optimised output loop. Duff’s device is an optimized implementation of a serial copy that uses a technique widely applied in assembly language for loop unwinding. It is perhaps the most dramatic use of case label fall-through in the C programming language to date.

Read More