Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!philabs!prls!amdimage!amdcad!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Cryptic C code? Message-ID: <2663@sun.uucp> Date: Sun, 18-Aug-85 20:11:52 EDT Article-I.D.: sun.2663 Posted: Sun Aug 18 20:11:52 1985 Date-Received: Wed, 21-Aug-85 06:26:18 EDT References: <359@tektools.UUCP> <32700002@siemens.UUCP> <170@laidbak.UUCP> Organization: Sun Microsystems, Inc. Lines: 15 > 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