From 17a16fefc4a932f39d77c5a647a9fd33b42f232b Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 5 Jun 2024 16:44:43 -0700 Subject: [PATCH] small optimization by moving blank check to top of loop --- lib/Perl/Tidy/Formatter.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index fc0e5a20..f12f3630 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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' ) { -- 2.39.5