Hmm, maybe I like this shift business and I'll use it. It makes sense. but I never thought about it because I don't like manipulating arrays without a good reason. It's micro optimisation and readability is better (sometimes) although that added line does disturb me a bit.
So I benchmarked it. of course it's blazing fast in any case. I did a minimal work in the subs. I'm not benchmarking king but the results surprised me. I ran with a count of 10^6, 10^7 and 5 . 10^7 The surprise was that there was an up to 6% speed difference and the biggest surprise is the inversion of which method is fastest. I'm curious, someone care to comment? Nadim. Rate shift copy shift 735294/s -- -1% copy 740741/s 1% -- Rate copy shift copy 720461/s -- -3% shift 739645/s 3% -- Rate shift copy shift 696379/s -- -6% copy 742611/s 7% -- with this code: cmpthese ( 50_000_000, { 'shift' => sub {_shift(@args)}, 'copy' => sub {_copy(@args)}, } ); sub _shift {my $self = shift; my ($x, $y, $z)=...@_ ; my $r = $x + $y + $z ; return $r ;} sub _copy {my ($self, $x, $y,$z) =...@_; my $r = $x + $y + $z ;return $r ;} +++ Johan Vromans [Fri, Sep 10, 2010 at 01:06:23PM +0200]: > Eric Wilhelm <enoba...@gmail.com> writes: > > > So, say the first half of the innards of foo() are being refactored to > > bar(), which will also take the original parameters in the same form: > > > > sub foo { > > my $self = shift; > > my %bar = $self->bar(@_); > > > > Don't forget SUPER: > > sub foo { > my $self = shift; > my %bar = $self->SUPER::foo(@_); > > -- Johan