String copy idiom.

Andrew Koenig ark at alice.UUCP
Sat Mar 9 08:35:59 AEST 1985


If s and t are char pointers in registers,

	while (*s++ = *t++) ;

generates the best code I could possibly imagine.

	while ((*s = *t) != '\0') {s++; t++;}

is considerably worse.  Try it with register variables on your compiler.



More information about the Comp.lang.c mailing list