splice not necessary to parse @_ in subroutines
Hi,
I saw that you are using splice to parse @_ into individual variables in subroutines, e.g. my ( $class, $uri ) = splice @_;
This is not necessary. For the individual variables the above code equivalent to my ( $class, $uri ) = @_;
The only difference is that using splice, @_ gets emptied (which costs time).
So leaving away splice has the following advantages:
-
identical bahaviour
-
smaller code (1,5k in all ;-)
-
maybe a bit of speed gain ;-)
-
option to reuse @_ or parts of it for subroutines to be called, e.g.
sub routineA { # @_ may contain more than 2 elements my (
x,
y) = @;
my $z = routineB(@); # all elements passed ... }I.e. no need to parse & copy all variables in routineA if they are used only in routineB.
Thanks for considering this optimization.