From: Steve Hancock Date: Sun, 11 Oct 2020 13:14:08 +0000 (-0700) Subject: minor efficiency improvements X-Git-Tag: 20201001.02~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aae6fc00b912c8275863cb4220935cf5f6b15c74;p=perltidy.git minor efficiency improvements --- diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 56dbeb8a..05ba52d4 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -244,9 +244,7 @@ sub initialize_for_new_group { } sub group_line_count { - my $self = shift; - my $nlines = @{ $self->[_rgroup_lines_] }; - return $nlines; + return +@{ $_[0]->[_rgroup_lines_] }; } # interface to Perl::Tidy::Diagnostics routines @@ -311,15 +309,6 @@ sub get_recoverable_spaces { return ref($indentation) ? $indentation->get_recoverable_spaces() : 0; } -sub make_alignment { - my ($col) = @_; - - # make one new alignment at column $col - my $alignment = - Perl::Tidy::VerticalAligner::Alignment->new( column => $col, ); - return $alignment; -} - sub maximum_line_length_for_level { # return maximum line length for line starting with a given level @@ -478,9 +467,9 @@ sub valign_input { my $cached_line_flag = get_cached_line_flag(); my $cached_seqno = get_cached_seqno(); if ($rvertical_tightness_flags) { - if ( $self->group_line_count() <= 1 - && $cached_line_type + if ( $cached_line_type && $cached_seqno + && $self->group_line_count() <= 1 && $rvertical_tightness_flags->[2] && $rvertical_tightness_flags->[2] == $cached_seqno ) { @@ -1378,7 +1367,8 @@ sub install_new_alignments { $col += $rfield_lengths->[$j]; # create initial alignments for the new group - my $alignment = make_alignment($col); ##, $token ); + my $alignment = + Perl::Tidy::VerticalAligner::Alignment->new( column => $col ); $new_line->set_alignment( $j, $alignment ); } return;