Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!uw-beaver!mit-eddie!fenchurch.mit.edu!jbs From: jbs@fenchurch.MIT.EDU (Jeff Siegal) Newsgroups: comp.lang.c Subject: Re: Explanation, please! Message-ID: <9957@eddie.MIT.EDU> Date: 26 Aug 88 12:53:49 GMT References: <638@paris.ICS.UCI.EDU> <2873@ttrdc.UUCP> Sender: uucp@eddie.MIT.EDU Reply-To: jbs@fenchurch.MIT.EDU (Jeff Siegal) Organization: MIT EE/CS Computer Facilities, Cambridge, MA Lines: 35 In article <2873@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >>[Duff's device loop example from C++ book] > >Question: what if count==0? The program breaks. I prefer (and also use, in highly-speed-sensitive code): #define duff16(counter, block) \ switch (counter & 0x0f) { \ do \ { \ counter -= 16; \ { block; } \ case 15: { block; } \ case 14: { block; } \ case 13: { block; } \ case 12: { block; } \ case 11: { block; } \ case 10: { block; } \ case 9: { block; } \ case 8: { block; } \ case 7: { block; } \ case 6: { block; } \ case 5: { block; } \ case 4: { block; } \ case 3: { block; } \ case 2: { block; } \ case 1: { block; } \ case 0: /* null statement */; \ } while (counter >= 16); \ } duff16(n, *to++ = *from++) Jeff Siegal