From: Steve Hancock Date: Wed, 21 Oct 2020 01:06:07 +0000 (-0700) Subject: unroll loop to speedup sub K_previous_nonblank X-Git-Tag: 20201001.03~47 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c0cfba610aab7803df06258665fc6f576cd04c86;p=perltidy.git unroll loop to speedup sub K_previous_nonblank --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 25a5167c..c8c4edcf 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5536,6 +5536,14 @@ sub K_previous_nonblank { ); } my $Kpnb = $KK - 1; + return unless ($Kpnb >= 0); + return $Kpnb if ( $rLL->[$Kpnb]->[_TYPE_] ne 'b' ); + return unless ( --$Kpnb >= 0 ); + return $Kpnb if ( $rLL->[$Kpnb]->[_TYPE_] ne 'b' ); + + # Backup loop. We should not get here unless some routine + # slipped repeated blanks into the token stream. + return unless ( --$Kpnb >= 0 ); while ( $Kpnb >= 0 ) { if ( $rLL->[$Kpnb]->[_TYPE_] ne 'b' ) { return $Kpnb } $Kpnb--; @@ -5543,6 +5551,7 @@ sub K_previous_nonblank { return; } + sub get_old_line_index { # return index of the original line that token K was on