From 6ac8a231969a1f29a22104327cce15a8ba81b206 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 17 Jul 2022 06:40:26 -0700 Subject: [PATCH] add PC policy Subroutines::RequireArgUnpacking --- .perlcriticrc | 5 ++--- lib/Perl/Tidy/Formatter.pm | 4 ++-- lib/Perl/Tidy/VerticalAligner.pm | 6 +++--- lib/Perl/Tidy/VerticalAligner/Line.pm | 5 ++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.perlcriticrc b/.perlcriticrc index 2ef70d96..b52435f9 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -43,9 +43,8 @@ verbose = %f: [%p] %m at line %l, column %c.\n # Nested subs are used for error handling in Tidy.pm. [-Subroutines::ProhibitNestedSubs] -# In critical routines this can significantly reduce processing speed. -# So we have to skip it. -[-Subroutines::RequireArgUnpacking] +[Subroutines::RequireArgUnpacking] +short_subroutine_statements = 2 # Completely Disagree. The advantages of 'use constant' greatly outweigh the # few disadvantages. Perl::Tidy relies heavily on constants for efficient and diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 2840539c..0920de7e 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -24515,8 +24515,8 @@ sub pad_token { @{is_binary_type}{@q} = (1) x scalar(@q); # token keywords which prevent using leading word as a container name - @_ = qw(and or err eq ne cmp); - @is_binary_keyword{@_} = (1) x scalar(@_); + @q = qw(and or err eq ne cmp); + @is_binary_keyword{@q} = (1) x scalar(@q); # Some common function calls whose args can be aligned. These do not # give good alignments if the lengths differ significantly. diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index c9dc2cd9..d6b0c4fe 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -4944,9 +4944,9 @@ sub combine_fields { my $jmax_new = $line_0->{'jmax'}; $new_alignments[ $jmax_new - 1 ] = $old_alignments[ $jmax_old - 1 ]; - $new_alignments[$jmax_new] = $old_alignments[$jmax_old]; - $line_0->{'ralignments'} = \@new_alignments; - $line_1->{'ralignments'} = \@new_alignments; + $new_alignments[$jmax_new] = $old_alignments[$jmax_old]; + $line_0->{'ralignments'} = \@new_alignments; + $line_1->{'ralignments'} = \@new_alignments; return; } diff --git a/lib/Perl/Tidy/VerticalAligner/Line.pm b/lib/Perl/Tidy/VerticalAligner/Line.pm index a03191ec..604a4ec6 100644 --- a/lib/Perl/Tidy/VerticalAligner/Line.pm +++ b/lib/Perl/Tidy/VerticalAligner/Line.pm @@ -42,10 +42,9 @@ EOM return $self; } - # This sub is called many times and has been optimized a bit sub get_column { - ##my ( $self, $j ) = @_; - my $alignment = $_[0]->{ralignments}->[ $_[1] ]; + my ( $self, $j ) = @_; + my $alignment = $self->{ralignments}->[$j]; return unless defined($alignment); return $alignment->get_column(); } -- 2.39.5