From: Steve Hancock Date: Tue, 20 Feb 2024 15:28:45 +0000 (-0800) Subject: tokenizer optimization X-Git-Tag: 20240202.03~17 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=be96dbb6d57d68970d5dd50c9c1e59634c2121da;p=perltidy.git tokenizer optimization saves about 0.25% run time by avoiding numerous calls --- 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