Explanation, please!
T. William Wells
bill at proxftl.UUCP
Mon Aug 29 17:58:01 AEST 1988
In article <1988Aug28.031926.19222 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
: In article <634 at proxftl.UUCP> bill at proxftl.UUCP (T. William Wells) writes:
: >[Duff's Device]
: >The false god of efficiency has reared it ugly head. This
: >routine would be imagined to be more efficient than the almost
: >equivalent: ...
: > while (--count >= 0)
: > *to++ = *from++;
: >
: >However, it often (always?) is not...
:
: On the contrary, it often (usually?) is. This is from experience, not
: theory. (Specifically, experience in C News and related code.)
Well, I'll bow to experimental evidence. However, that does make
me wish that more compilers went to the effort to deal with this
kind (the "unoptimized" version) of loop, seeing as how it is so
commonly important.
: In general, however, in the long run the correct way to implement bulk
: data copying is to call "memcpy", which (in the long run) is likely
: to be recognized and given special attention by most compilers.
Agreed. That is how I would wish it to be done.
---
Bill
novavax!proxftl!bill
More information about the Comp.lang.c
mailing list