2009/6/7 The Holy ettlz <theholyet...@googlemail.com>:
> On Sun, 2009-06-07 at 20:34 +0100, Hugo Mills wrote:
>> >
>> > Hmm. I'd choose Style A since with Style B there's a chance I'd have to
>> > discard one result and evaluate three things. Unless there's some
>> > parallel funny-stuff... what's the probability of can_use_fast_path?
>>
>>    *shrug* Who knows?
>>
>>    This is entirely hypothetical. The question came to mind while I
>> was looking at some code someone else had written, in Style B, where I
>> usually use Style A.
>
> Well beats me. Unless some miracle happens in optimisation.

If one of the paths is more than a few lines I would probably opt for

if( can_fast_path )
{
  #do fast
}
else
{
  #do slow
}

purely because I think it remains more readable to have each in a
block that stays indented and with the if makes it more obvious that
it is either/or and that there is no reason the code should run
anything other than only one of the blocks

Anton

-- 
Anton Piatek
email: an...@piatek.co.uk       
blog/photos:                    http://www.strangeparty.com
pgp: [0xB307BAEF]       (http://www.strangeparty.com/anton.asc)
fingerprint: 116A 5F01 1E5F 1ADE 78C6 EDB3 B9B6 E622 B307 BAEF

No trees were destroyed in the sending of this message, however, a
significant number of electrons were terribly inconvenienced.

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------

Reply via email to