Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.lang.c Subject: Re: more questions about efficient C code Message-ID: <5745@utzoo.UUCP> Date: Sat, 29-Jun-85 18:50:44 EDT Article-I.D.: utzoo.5745 Posted: Sat Jun 29 18:50:44 1985 Date-Received: Sat, 29-Jun-85 18:50:44 EDT References: <474@crystal.UUCP> <397@umcp-cs.UUCP> <721@wlcrjs.UUCP>, <496@umcp-cs.UUCP> Organization: U of Toronto Zoology Lines: 31 > Seriously, the difference in the fopen call is pretty small, but > the difference in something like > > for (...) > for (...) { > if ((j = (k >> 2) - m) == 0) > k++; > } > > can be important. Once you get into the habit of testing the results > of an assignment, it doesn't even look funny anymore. Retch. To quote the "Indian Hill C Style" paper: For example, the code: .DS a = b + c; d = a + r; .DE should not be replaced by .DS d = (a = b + c) + r; .DE even though the latter may save one cycle. Note that in the long run the time difference between the two will decrease as the optimizer gains maturity, while the difference in ease of maintenance will increase as the human memory of what's going on in the latter piece of code begins to fade... -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry