void duff(register char *to, register char *from, register int count)
{
register int 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);
}
}
是上述有效的C代碼?如果是這樣,它試圖達到什麼目的,爲什麼會有人做類似上述的事情?
最好使'count'無符號,或者添加'7U'而不是'7'。否則,鴻溝會很慢。 – 2010-08-02 05:58:30
[代碼是做什麼的絕對重複?](http://stackoverflow.com/questions/1723270/what-does-the-code-do) – paxdiablo 2010-08-02 06:04:29
@R ..:呃,不。你真的認爲編譯器太笨了,無法「優化」整數除法? – GManNickG 2010-08-02 06:17:38