Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!munnari.oz.au!brolga!bunyip.cc.uq.oz.au!oat!qut.edu.au!zsinwatt From: zsinwatt@qut.edu.au (James Watt) Newsgroups: comp.lang.c Subject: Re: Just a little something that has been bothering me. Message-ID: <1990Dec19.105418.21863@qut.edu.au> Date: 19 Dec 90 15:54:18 GMT References: <2753F21B.2F6@tct.uucp> <1990Nov30.180913.20890@clear.com> Organization: Queensland University of Technology Lines: 37 In article , rlf@dptspd.sat.datapoint.com (Rory Foster) writes: > sven@cs.widener.edu (Sven Heinicke) writes: > >>What is quicker? > >> int a = 0,i = 0; > >>or > >> int a,i; >> i = a = 0; > >>and why? > >>This type of thing has been bothering me for a long time. > > > Well, I looked at it and (without optimizing) the first case was "quicker". > I was using the UNIX SVR4 C compiler. If your compiler has an assembly option, > (-S in Johnson's PCC) use it to see for yourself. > > When I optimize, my compiler shows no difference. So there you have it, > it sort of just depends on what you're using at the time. On a HP9000 840 ( without optimisation), one is better than two, and with optimization they are basically similar. However if you use the int a,i=0; form of declaration and optimize it, it outperforms both one and two. In reality there are far too many variables to make this kind of exercise have any real relevance to the meaning of life in general. -- |----------------------------------------------------------------------------| | James Watt | AARnet: james@water.fit.qut.edu.au ARPA: ZSINWATT@QUT.EDU.AU | |----------------------------------------------------------------------------|