Skip to content

Commit 14d45d8

Browse files
committed
convert some method arg handling from shift to unpacking
1 parent 6809959 commit 14d45d8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/PPI/Node.pm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -714,40 +714,40 @@ sub __position {
714714

715715
# Insert one or more elements before a child
716716
sub __insert_before_child {
717-
my $self = shift;
718-
my $key = refaddr shift;
717+
my ( $self, $child, @insertions ) = @_;
718+
my $key = refaddr $child;
719719
my $p = List::Util::first {
720720
refaddr $self->{children}[$_] == $key
721721
} 0..$#{$self->{children}};
722-
foreach ( @_ ) {
722+
foreach ( @insertions ) {
723723
Scalar::Util::weaken(
724724
$_PARENT{refaddr $_} = $self
725725
);
726726
}
727-
splice( @{$self->{children}}, $p, 0, @_ );
727+
splice( @{$self->{children}}, $p, 0, @insertions );
728728
1;
729729
}
730730

731731
# Insert one or more elements after a child
732732
sub __insert_after_child {
733-
my $self = shift;
734-
my $key = refaddr shift;
733+
my ( $self, $child, @insertions ) = @_;
734+
my $key = refaddr $child;
735735
my $p = List::Util::first {
736736
refaddr $self->{children}[$_] == $key
737737
} 0..$#{$self->{children}};
738-
foreach ( @_ ) {
738+
foreach ( @insertions ) {
739739
Scalar::Util::weaken(
740740
$_PARENT{refaddr $_} = $self
741741
);
742742
}
743-
splice( @{$self->{children}}, $p + 1, 0, @_ );
743+
splice( @{$self->{children}}, $p + 1, 0, @insertions );
744744
1;
745745
}
746746

747747
# Replace a child
748748
sub __replace_child {
749-
my $self = shift;
750-
my $old_child_addr = refaddr shift;
749+
my ( $self, $old_child, @replacements ) = @_;
750+
my $old_child_addr = refaddr $old_child;
751751

752752
# Cache parent of new children
753753
my $old_child_index = List::Util::first {
@@ -756,14 +756,14 @@ sub __replace_child {
756756

757757
return undef if !defined $old_child_index;
758758

759-
foreach ( @_ ) {
759+
foreach ( @replacements ) {
760760
Scalar::Util::weaken(
761761
$_PARENT{refaddr $_} = $self
762762
);
763763
}
764764

765765
# Replace old child with new children
766-
splice( @{$self->{children}}, $old_child_index, 1, @_ );
766+
splice( @{$self->{children}}, $old_child_index, 1, @replacements );
767767

768768
# Uncache parent of old child
769769
delete $_PARENT{$old_child_addr};

0 commit comments

Comments
 (0)