Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site cca.UUCP
Path: utzoo!linus!decvax!cca!larry
From: larry@cca.UUCP (Laurence Schmitt)
Newsgroups: net.lang.c
Subject: Re: more questions about efficient C code
Message-ID: <3367@cca.UUCP>
Date: Fri, 19-Jul-85 08:17:30 EDT
Article-I.D.: cca.3367
Posted: Fri Jul 19 08:17:30 1985
Date-Received: Mon, 19-Aug-85 23:56:30 EDT
Organization: Computer Corp. of America, Cambridge
Lines: 20



>> 3) Is there really much to be gained by using assignment within
>>    a boolean expression, for example, is
>>
>>	if ((fp = fopen("foo", "r") == NULL) {
>>
>>    really that much faster than
>>
>>	fp = fopen("foo", "r");
>>	if (fp == NULL) {
>
>Again, depends: if "fp" is not a register, the assignment+test is faster,
>since you end up branching after the assignment from r0 to "fp".  If it
>is a register, it comes out the same.  (At least after optimization, usually).
>The first form is never slower, anyway.

In Lattice C on the IBM-PC the two constructs compile exactly the same--no
register declarations involved.