Pigeon's Device is a C programming technique similar to Duff's Device, using switch-case fall-through for conditional execution based on a mode parameter. It originated in an MS-DOS program for comparing date/time records with different sort orders. The article presents the technique's structure and a historical example, though it's more of a curiosity than a widely applicable optimization.
Background
Duff's Device is a well-known C programming technique for loop unrolling that exploits switch-case fall-through. Pigeon's Device is a lesser-known, independently discovered variant with similar structural quirks.
- Source
- Lobsters
- Published
- Mar 21, 2026 at 11:32 PM
- Score
- 5.0 / 10