Explanation, please!
Dave Martindale
dave at onfcanim.UUCP
Tue Aug 30 04:01:20 AEST 1988
In article <1988Aug28.031926.19222 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>
>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.
For the case of copying bytes, yes. But there are other operations
done in tight loops that do a bit more work than a simple byte move,
so memcpy is not usable, yet little enough that unrolling the loop
is still worthwhile. Thus Duff's Device will remain useful, until
all compilers are smart enough to do loop unrolling on their own.
For example: move while packing or unpacking data, table lookup, perhaps
CRC generation.
Dave Martindale
More information about the Comp.lang.c
mailing list