]> git.donarmstrong.com Git - perltidy.git/commitdiff
small optimization by moving blank check to top of loop
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 5 Jun 2024 23:44:43 +0000 (16:44 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 5 Jun 2024 23:44:43 +0000 (16:44 -0700)
lib/Perl/Tidy/Formatter.pm

index fc0e5a204aacb7b35fc4b01582596508b7b724db..f12f36300039bb9ceabca48908171f2ef390ff15 100644 (file)
@@ -34623,13 +34623,20 @@ sub xlp_tweak {
         my %token_count;
         for my $i ( $ibeg .. $iend ) {
 
+            my $type = $types_to_go[$i];
+
+            # handle a blank space
+            if ( $type eq 'b' ) {
+                $patterns[$j] .= $type;
+                next;
+            }
+
             #-------------------------------------------------------------
             # Part 1: keep track of containers balanced on this line only.
             #-------------------------------------------------------------
             # These are used below to prevent unwanted cross-line alignments.
             # Unbalanced containers already avoid aligning across
             # container boundaries.
-            my $type = $types_to_go[$i];
             if ( $type_sequence_to_go[$i] ) {
                 my $token = $tokens_to_go[$i];
                 if ( $is_opening_token{$token} ) {
@@ -34848,11 +34855,7 @@ sub xlp_tweak {
             # Part 3: continue accumulating the next pattern
             #-----------------------------------------------
 
-            if ( $type eq 'b' ) {
-                $patterns[$j] .= $type;
-            }
-
-            elsif ( $is_k_w_n_C_bang{$type} ) {
+            if ( $is_k_w_n_C_bang{$type} ) {
 
                 # for keywords we have to use the actual text
                 if ( $type eq 'k' ) {