]> git.donarmstrong.com Git - perltidy.git/commitdiff
simplify logic
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 2 Oct 2023 15:06:46 +0000 (08:06 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 2 Oct 2023 15:06:46 +0000 (08:06 -0700)
lib/Perl/Tidy/Tokenizer.pm

index a88fac530741935f882b8014860c0d99cc1323cf..726b9dfa02111311ef07e400eb28c8a68ff83cb0 100644 (file)
@@ -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 {