From: Steve Hancock Date: Mon, 2 Oct 2023 15:06:46 +0000 (-0700) Subject: simplify logic X-Git-Tag: 20230912.03~12 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=02abf1383cf43b2da4f25bbc74d280f2167e9a65;p=perltidy.git simplify logic --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index a88fac53..726b9dfa 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -9003,35 +9003,33 @@ sub find_next_nonblank_token { } my $next_nonblank_token = $rtokens->[ ++$i ]; + + # Any more tokens? return ( SPACE, $i ) if ( !defined($next_nonblank_token) || !length($next_nonblank_token) ); - # Quick test for nonblank ascii char. Note that we just have to - # examine the first character here. + # Skip over whitespace my $ord = ord( substr( $next_nonblank_token, 0, 1 ) ); - if ( $ord >= ORD_PRINTABLE_MIN - && $ord <= ORD_PRINTABLE_MAX ) - { - return ( $next_nonblank_token, $i ); - } + if ( - # Quick test to skip over an ascii space or tab - elsif ( $ord == ORD_SPACE || $ord == ORD_TAB ) { - $next_nonblank_token = $rtokens->[ ++$i ]; - return ( SPACE, $i ) unless defined($next_nonblank_token); - } + ( $ord <= ORD_PRINTABLE_MIN || $ord >= ORD_PRINTABLE_MAX ) - # Slow test to skip over something else identified as whitespace - elsif ( $next_nonblank_token =~ /^\s*$/ ) { + # Quick test for ascii space or tab + && ( + ( $ord == ORD_SPACE || $ord == ORD_TAB ) + + # Slow test to for something else identified as whitespace + || $next_nonblank_token =~ /^\s+$/ + ) + ) + { $next_nonblank_token = $rtokens->[ ++$i ]; return ( SPACE, $i ) unless defined($next_nonblank_token); } - else { - ## at nonblank - } # We should be at a nonblank now return ( $next_nonblank_token, $i ); + } ## end sub find_next_nonblank_token sub find_next_noncomment_token {