in reply to Which code executes faster

The statement modifier form,

return 1 if $n < 1;
should be a bit faster, since no lexical scope is created. Faster yet could be,
return $n < 1;
if that's what you want to happen when the test fails.

In most non-trivial code it's not going to make any noticeable difference.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Which code executes faster
by reasonablekeith (Deacon) on Jul 31, 2006 at 08:03 UTC
    Faster yet could be.
    hmm, like Yoda do you speak. ;)

    seriously though alandev, there is unlikely to be a real world increase in speed. You should go with whatever's going to be easiest for you (and the programmer who comes after you) to read.

    ---
    my name's not Keith, and I'm not reasonable.
Re^2: Which code executes faster
by alandev (Scribe) on Jul 31, 2006 at 05:04 UTC
    thanks zaxo