http://qs321.pair.com?node_id=895465


in reply to Re: Is undef list assignment a no-op?
in thread Is undef list assignment a no-op?

Small oversight - your benchmark with $unused never makes an assignment from @_. When I fixed the typo and reran it, (undef, $x)= @_ was marginally faster than ($unused, $x) = @_ though not by an amount I consider significant (3%). -- Tested on Perl 5.10.0, system Perl for Debian Lenny, 32bit.

use Benchmark qw(cmpthese); my $a1='a'x1e6; my $b1=12345; cmpthese -1,{ a=>q[ sub{ my( undef, $x) = @_ }->( $a1, $b1 ) ], b=>q[ sub{ my $x = $_[1] }->( $a1, $b1 ) ], c=>q[ sub{ my( $unused, $x ) = @_;}->( $a1, $b1 ) ], }; # Output Rate c a b c 649176/s -- -3% -33% a 670690/s 3% -- -30% b 963764/s 48% 44% --

Update added Perl version and platform; clarified ranking of results.