in reply to Timing of Array-Size Determination Methods
sub size_index { my $val2 = $#array + 1; }
Just... don't... do... that!! Express what you *mean* or use some obfuscational language like C, (non-parrot) assembler or Java. If you want to express "if not" then type "if not". If you mean "unless", then use "unless". If you mean array size then DON'T say "index of the last element plus one".
Is scalar(@array) is slower because it requires a function call?
Yes. But don't let its being slower stop you from using it. 1.8 million per second or 3.2 million per second -- if that matters, Perl is not the right tool for the job.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Timing of Array-Size Determination Methods (scalar() != function)
by Aristotle (Chancellor) on Jun 02, 2003 at 23:58 UTC | |
by Juerd (Abbot) on Jun 03, 2003 at 05:32 UTC | |
by Aristotle (Chancellor) on Jun 03, 2003 at 11:11 UTC |