Pigeon's Device: An Independent Loop Optimization Technique in C Programming
By
gaul
An everything bagel for the brain. Substantive, layered, well-seasoned.
Summary
The article introduces Pigeon's device, a loop optimization technique in C programming that was independently developed from Duff's device. The author explains that they created this technique for MS-DOS programming before learning about Duff's device, and describes how Pigeon's device was originally used in a function for comparing date/time records with different sort orders. The article compares the two techniques and discusses their similarities and differences in implementation.
Key quotes
· 5 pulledMany may have heard tell of Duff's device, a rather neat loop optimisation technique in C.
This page provides details of Pigeon's device - a related but independently-originated technique.
The original instantiation of Pigeon's device was in a piece of C code written for MS-DOS before the days of the internet, so I had not heard of Duff's device.
When I did, the similarity between the techniques was immediately apparent.
The original Pigeon's device was in a function for comparing two date/time records in various different manners according to the desired sort order - FORWARD, forward chr
You might also wanna read
Cscript Style Guide: A Python-Inspired Approach to C Programming
Cscript is presented as a style guide for writing C code that aims to make C development faster and more Python-like while maintaining C's p
Implementing Closures in C Using JIT-Compiled Wrappers for Win32 Window Procedures
The article discusses an advanced programming technique for creating closures in C using JIT-compiled wrappers, specifically applied to Win3
Guidelines for Writing Fully Encapsulated C Programs: Pure vs Performance Approaches
This article presents a comprehensive set of rules and guidelines for writing fully encapsulated C programs, developed by the author over ye
Checked-size Array Parameters in C: Addressing Safety Issues with Array Size Validation
The article discusses a recent attempt to add safety checks for array parameters in the C programming language, specifically within the cryp
Creating a Leak-Free, Thread-Safe Grep Utility in C23 with Safe Programming Practices
The article details the author's experience creating a leak-free, thread-safe grep utility in C23 using a custom header file called safe_c.h
Implementing Generic Programming in C: Techniques and Trade-offs
The article explains how to implement generic programming in C despite the language not having built-in generics support. It covers various
