Duff's Device – The C Speed Hack From 1983en.wikipedia.org 2 pointsbananamogul1 month ago2 commentsSaveHideCopy link On HNComments−gruntled-worker1moThe Wikipedia version is simplified, but it bears mentioning that as written, it's going to be slower than the trivial version for most N's on 1983 compilers and systems. Fixed: register n = (count + 7) >> 3; switch (count - (n << 3))−JohnFen1moI love Duff's Device. I used it to great effect back in the day, and still use it from time to time in my personal projects, just for old time's sake,
Comments
The Wikipedia version is simplified, but it bears mentioning that as written, it's going to be slower than the trivial version for most N's on 1983 compilers and systems. Fixed:
I love Duff's Device. I used it to great effect back in the day, and still use it from time to time in my personal projects, just for old time's sake,