At 12:44 AM 4/20/2006, Chris Wagner wrote:
At 10:42 AM 4/20/2006 +1000, Sisyphus wrote:
>On the subject of replacing brackets with modifiers (which I think was also
>raised earlier on), I was surprised to find that using a modifier is about
>25% faster than brackets:
>'modifier' => 'for(@x) {$z1++ if $_ != 3}',
>'brackets' => 'for(@y) {if($_ != 3){$z2++}}',
That is actually pretty well known. The reason is that the former is a
short circuit style operation. The code has a simple bifurcation. In the
latter it is a code block which has to be setup for all the potential things
u can put in a code block. Like my's, labels, etc. Simply entering a curly
bracket costs money. That's why it's best to avoid them unless ur stringing
just way too many and's and or's together.
And is there some reason that the compiler couldn't optimize that
away by checking
to see if there are any my's, labels, etc. and avoiding the setup in that case?
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs