String copy idiom.
Daniel J. Salomon
djsalomon at watdaisy.UUCP
Fri Mar 8 12:57:26 AEST 1985
A recent article on language idioms gave the following C code
for a string copy:
while (*s++ = *t++);
Serious C hackers should know that on VAX 4.2 BSD UNIX this
code produces a loop with 50% more assembler instructions
than the slightly clearer sequence:
while ((*s = *t) != '\0')
{ s++;
t++;
}
This is true whether or not the object-code improver
is invoked, and may be true on other machines as well.
More information about the Comp.lang.c
mailing list