From c5955896afe223170e2f9a8c9336f0d6fb0853ca Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 3 Sep 2021 18:15:32 -0700 Subject: [PATCH] eliminate sub 'make_side_comment' --- lib/Perl/Tidy/VerticalAligner.pm | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 747f786d..3c453227 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -656,8 +656,13 @@ sub valign_input { # It simplifies things to create a zero length side comment # if none exists. # -------------------------------------------------------------------- - $self->make_side_comment( $rtokens, $rfields, $rpatterns, $rfield_lengths ); - $jmax = @{$rfields} - 1; + if ( ( $jmax == 0 ) || ( $rtokens->[ $jmax - 1 ] ne '#' ) ) { + $jmax += 1; + $rtokens->[ $jmax - 1 ] = '#'; + $rfields->[$jmax] = ''; + $rfield_lengths->[$jmax] = 0; + $rpatterns->[$jmax] = '#'; + } # -------------------------------------------------------------------- # create an object to hold this line @@ -772,25 +777,6 @@ sub join_hanging_comment { return 1; } -sub make_side_comment { - - # create an empty side comment if none exists - - my ( $self, $rtokens, $rfields, $rpatterns, $rfield_lengths ) = @_; - - my $jmax = @{$rfields} - 1; - - # if line does not have a side comment... - if ( ( $jmax == 0 ) || ( $rtokens->[ $jmax - 1 ] ne '#' ) ) { - $jmax += 1; - $rtokens->[ $jmax - 1 ] = '#'; - $rfields->[$jmax] = ''; - $rfield_lengths->[$jmax] = 0; - $rpatterns->[$jmax] = '#'; - } - return; -} - { ## closure for sub decide_if_list my %is_comma_token; -- 2.39.5