]> git.donarmstrong.com Git - perltidy.git/commitdiff
unroll loop to speedup sub K_previous_nonblank
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 21 Oct 2020 01:06:07 +0000 (18:06 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 21 Oct 2020 01:06:07 +0000 (18:06 -0700)
lib/Perl/Tidy/Formatter.pm

index 25a5167ceeb67b26da9acc785ff57d258fd6dec7..c8c4edcf2e3cfcb3baeb50867fd175bdff78b709 100644 (file)
@@ -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