Duff's device
Unusual C programming idiom that manually implements loop unrolling using interleaved control structures
In the C programming language, Duff's device is a way of manually implementing loop unrolling by interleaving two syntactic constructs of C: the do-while loop and a switch statement. Its discovery is credited to Tom Duff in November 1983, when Duff was working for Lucasfilm and used it to speed up a real-time animation program.
Nº Q1264012 ★
Common · Knowledge
Duff's device
Unusual C programming idiom that manually implements loop unrolling using interleaved control structures
In the C programming language, Duff's device is a way of manually implementing loop unrolling by interleaving two syntactic constructs of C: the do-while loop and a switch statement. Its discovery is credited to Tom Duff in November 1983, when Duff was working for Lucasfilm and used it to speed up a real-time animation program.
From Wikipedia
In the C programming language, Duff's device is a way of manually implementing loop unrolling by interleaving two syntactic constructs of C: the do-while loop and a switch statement. Its discovery is credited to Tom Duff in November 1983, when Duff was working for Lucasfilm and used it to speed up a real-time animation program. Loop unrolling attempts to reduce the overhead of conditional branching needed to check whether a loop is done, by executing a batch of loop bodies per iteration. To handle cases where the number of iterations is not divisible by the unrolled-loop increments, a common technique among assembly language programmers is to jump directly into the middle of the unrolled loop body to handle the remainder. Duff implemented this technique in C by using C's case label fall-through feature to jump into the unrolled body.
Text: Wikipédia, CC BY-SA 4.0. ·
Related cards
-
D
Duplicate code
Piece of source code that occurs more than once in the same environment
Nº Q1105830 ★
-
D
Dc (computer program)
Cross-platform reverse-Polish calculator program
Nº Q344670 ★
-
Turbo C
Discontinued C IDE and compiler
Nº Q1144729 ★★
-
B
Beowulf cluster
Parallel computing cluster of networked commodity computers
Nº Q818610 ★
-
Alan Kay
American computer scientist (born 1940)
Nº Q92742 ★★★
-
i
instruction
Single operation of a computer
Nº Q925783 ★★