Duff’s Device Is a Lie. Here’s the Truth.
Duff’s Device is revered as the most elegant optimization in C history — a switch-case fused with a do-while loop to unroll iteration. But on the very systems it was designed for, it was often slower than the naive loop it replaced. The real lesson isn’t about cleverness. It’s about the discipline of benchmarking and the danger of revering patterns instead of measuring them.