Cryptic C code?

Guy Harris guy at sun.uucp
Mon Aug 19 10:11:52 AEST 1985


> As to efficiency (of "if (*p++ = *q++)" vs "if ((*p++ = *q++) == '\0')"
> - gh), that would depend upon the hardware and
> the cleverness of the compiler.  If the machine sets
> a zero flag when a '\0' is transferred, then a
> "branch if zero" type of intruction can be immediately executed,
> without additionally comparing the character to 0.
> Whether the compiler takes advantage of this is another matter...

What??  I dunno about your compilers, but every one I've worked with
generates the exact same code for both constructs; some may even convert the
first to the second in their internal representation (it's been too long
since I've poked inside PCC to remember).  It doesn't take much in the way
of compiler technology to make the efficiency issue irrelevant in this case.

	Guy Harris



More information about the Comp.lang.c mailing list