Possible duplicate:What does the code do?
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); } }
Is the above C code? If so, what is he trying to achieve and why would someone do something like this above?
It's called a Duff device, and you can read about it on wikipedia .
: . , , Duff, , .
, , , :
void memcpy(char* dst, char* src, size_t count) { begin: if (count-- == 0) return; *(dst++) = *(src++); goto begin; }
15 , :
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
, " " "".
duff, , :
, , , , , , , , , , , , , , , , , , ,
. .
, , , , , , ceil (n/8).
register - , , , , .
, (memcpy(), , , ), , , , .
Mandatory link to Duff Device on Wikipedia .
Source: https://habr.com/ru/post/1757602/More articles:Set AutoFac to use PropertiesAutowired (true) by default? - dependency-injectionIs it possible to use named and optional arguments in ironpython - .netiphone mapkit: there are pins dropped one by one - iphonehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1757600/ironpython-named-parameters-to-constructor&usg=ALkJrhhIZ2eVLFk4T8r5PPdSBSOHGxu3GQChecking whether a class has a related primitive type - javaHow to rotate an image using a client solution - javascriptHide keyboard in UIWebView - iphoneget id of draggable div when dragging if i have many draggable div.using jquery - jqueryErlang internal function recursion - erlangOpen Source Java EE Presentation Environment - javaAll Articles