I was wrong about Duff’s device

Duff’s device is a C language technique that looks like this: send(to, from, count) { register n = (count + 7) / 8; switch (count % 8) { case 0: do { to = from++; case 7: to = from++; case 6: to = from++; case 5: to = from++; case 4: to = from++; case 3: to = from++; case 2: to = from++; case 1: to = from++; } while (--n > 0); } } It achieves two things: It unrolls the loop in chunks of eight. Unrolling the loop is when instead of telling the computer “do X 5 times,” you say “do X do X do X

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论