Optimisation

Andy Armstrong andy at hexten.net
Mon Mar 2 21:11:29 GMT 2009


On 2 Mar 2009, at 21:01, Nigel Peck wrote:
> When the list could be empty, which is faster?
>
> if ( @list ) { foreach ( @list ) { } }
>
> - or just -
>
> foreach ( @list ) { }
>
> Or is it a pointless question?


Yes :)

Benchmark it - but I bet there's not much difference - and the second  
version will be faster in the non-empty case.

-- 
Andy Armstrong, Hexten



More information about the london.pm mailing list