On Thu, Nov 21, 2002 at 10:32:21PM -0500, Erik Price wrote:
> Or don't even bother with $#array since "$n <= @array" forces scalar 
> context to the array, which causes it to interpolate to the number of 
> elements.
> 
> Terser, quicker, more seductive.  Such is the way of the dark side of 
> Perl programming.  (Even if by only one char.)
> 

quicker? Its the same number of opcodes. the pp_av2arylen that $#array
uses is a little bit bigger than the pp_scalar used by scalar@array,
but that is probably offset by the more convoluted path that
scalar@array takes through rv2av.

This would be an odd place to look to for efficiency. Anyone who wants
to disagree with me can discuss it over coffee tomorrow in
boston.com's kitchen. The usual time.

[langmead@hynes langmead]$ dperl -D8 -e'@a=1..20;print $#a' 2>&1|tail
(-e:1)  null
(-e:1)  aassign
(-e:1)  nextstate
(-e:1)  pushmark
(-e:1)  gv(main::a)
(-e:1)  rv2av
(-e:1)  av2arylen
(-e:1)  print
(-e:1)  leave
19[langmead@hynes langmead]$


[langmead@hynes langmead]$ dperl -D8 -e'@a=1..20;print scalar @a' 2>&1|tail
(-e:1)  null
(-e:1)  aassign
(-e:1)  nextstate
(-e:1)  pushmark
(-e:1)  gv(main::a)
(-e:1)  rv2av
(-e:1)  scalar
(-e:1)  print
(-e:1)  leave
20[langmead@hynes langmead]$


-- 
Daddy, can we search on Google for it?  -- Samantha Langmead, age 5.
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to