From be96dbb6d57d68970d5dd50c9c1e59634c2121da Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 20 Feb 2024 07:28:45 -0800 Subject: [PATCH] tokenizer optimization saves about 0.25% run time by avoiding numerous calls --- lib/Perl/Tidy/Tokenizer.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index aee43b98..921428da 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -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 -- 2.39.5