]> git.donarmstrong.com Git - perltidy.git/commitdiff
minor optimization
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 4 Sep 2022 15:09:12 +0000 (08:09 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 4 Sep 2022 15:09:12 +0000 (08:09 -0700)
lib/Perl/Tidy/Tokenizer.pm

index 821ca601629306c2c840360d63763a1d6575f0ea..142bda03e374c670cbcdf081acf5c0f9688e8233 100644 (file)
@@ -5220,7 +5220,9 @@ EOM
 
                             # ...These include non-anonymous subs
                             # note: could be sub ::abc { or sub 'abc
-                            if ( $block_type_i =~ m/^sub\s*/gc ) {
+                            if ( substr( $block_type_i, 0, 3 ) eq 'sub'
+                                && $block_type_i =~ m/^sub\s*/gc )
+                            {
 
                                 # note: older versions of perl require the /gc
                                 # modifier here or else the \G does not work.
@@ -5294,11 +5296,13 @@ EOM
                     # that they will be at the same level as its container.  For
                     # commas, this simplifies the -lp indentation logic, which
                     # counts commas.  For ?: it makes them stand out.
-                    if ($nesting_list_flag) {
+                    if (
+                        $nesting_list_flag
                         ##      $type_i =~ /^[,\?\:]$/
-                        if ( $is_comma_question_colon{$type_i} ) {
-                            $in_statement_continuation = 0;
-                        }
+                        && $is_comma_question_colon{$type_i}
+                      )
+                    {
+                        $in_statement_continuation = 0;
                     }
 
                     # Be sure binary operators get continuation indentation.
@@ -5306,7 +5310,8 @@ EOM
                     # to add ci to binary operators following a 'try' block,
                     # or similar extended syntax block operator (see c158).
                     if (
-                        ( $nesting_block_flag || $nesting_list_flag )
+                           !$in_statement_continuation
+                        && ( $nesting_block_flag || $nesting_list_flag )
                         && (   $type_i eq 'k' && $is_binary_keyword{$tok_i}
                             || $is_binary_type{$type_i} )
                       )