]> git.donarmstrong.com Git - perltidy.git/commitdiff
tokenizer optimization
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 20 Feb 2024 15:28:45 +0000 (07:28 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 20 Feb 2024 15:28:45 +0000 (07:28 -0800)
saves about 0.25% run time by avoiding numerous calls

lib/Perl/Tidy/Tokenizer.pm

index aee43b9804a5fbd4f9d87505ca127a6328d1e9f6..921428dad716643872ec538bd8fd9dcfec4b15a0 100644 (file)
@@ -4731,8 +4731,18 @@ EOM
         #    true if this token ends the current line
         #    false otherwise
 
-        my ( $next_nonblank_token, $i_next ) =
-          $self->find_next_nonblank_token( $i, $rtokens, $max_token_index );
+        my $next_nonblank_token;
+        my $i_next = $i + 1;
+        if ( $i_next <= $max_token_index && $rtoken_type->[$i_next] eq 'b' ) {
+            $i_next++;
+        }
+        if ( $i_next <= $max_token_index ) {
+            $next_nonblank_token = $rtokens->[$i_next];
+        }
+        else {
+            ( $next_nonblank_token, $i_next ) =
+              $self->find_next_nonblank_token( $i, $rtokens, $max_token_index );
+        }
 
         # a bare word immediately followed by :: is not a keyword;
         # use $tok_kw when testing for keywords to avoid a mistake