]> git.donarmstrong.com Git - perltidy.git/commitdiff
eliminate 2 unused hashes
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 12 Apr 2022 13:44:15 +0000 (06:44 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 12 Apr 2022 13:44:15 +0000 (06:44 -0700)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm

index 9718fa015408b9dfb8bc562a27f181f8ad9878d3..d6edcfbe9c76e9b1585cacf1c023a71305be8742 100644 (file)
@@ -252,12 +252,16 @@ EOM
             elsif ( $filename eq '-' ) {
                 binmode STDOUT, ":raw:encoding(UTF-8)";
             }
+            else {
+                # shouldn't happen
+            }
         }
 
         # Case 2: handle unencoded data
         else {
             if    ( ref($fh) eq 'IO::File' ) { binmode $fh }
             elsif ( $filename eq '-' )       { binmode STDOUT }
+            else                             { }    # shouldn't happen
         }
     }
 
index db403dd30669a8c12f13e9c49d370c505e65e8fc..23af9e284746c948a4a82bf693d88b37b02ec90b 100644 (file)
@@ -206,6 +206,7 @@ my (
     %is_last_next_redo_return,
     %is_if_unless,
     %is_if_unless_elsif,
+    %is_if_unless_elsif_else,
     %is_and_or,
     %is_chain_operator,
     %is_block_without_semicolon,
@@ -225,8 +226,6 @@ my (
     # Initialized in check_options. These are constants and could
     # just as well be initialized in a BEGIN block.
     %is_do_follower,
-    %is_if_brace_follower,
-    %is_else_brace_follower,
     %is_anon_sub_brace_follower,
     %is_anon_sub_1_brace_follower,
     %is_other_brace_follower,
@@ -599,6 +598,9 @@ BEGIN {
     @q = qw(if unless elsif);
     @is_if_unless_elsif{@q} = (1) x scalar(@q);
 
+    @q = qw(if unless elsif else);
+    @is_if_unless_elsif_else{@q} = (1) x scalar(@q);
+
     @q = qw(and or err);
     @is_and_or{@q} = (1) x scalar(@q);
 
@@ -1564,13 +1566,6 @@ EOM
     push @dof, ',';
     @is_do_follower{@dof} = (1) x scalar(@dof);
 
-    # What tokens may follow the closing brace of an if or elsif block?
-    # Not used. Previously used for cuddled else, but no longer needed.
-    %is_if_brace_follower = ();
-
-    # nothing can follow the closing curly of an else { } block:
-    %is_else_brace_follower = ();
-
     # what can follow a multi-line anonymous sub definition closing curly:
     my @asf = qw# ; : => or and  && || ~~ !~~ ) #;
     push @asf, ',';
@@ -4169,11 +4164,6 @@ EOM
 
             }
 
-            # good to break before 'if', 'unless', etc
-            if ( $is_if_brace_follower{$next_nonblank_token} ) {
-                $bond_str = VERY_WEAK;
-            }
-
             if ( $next_nonblank_type eq 'k' && $type ne 'CORE::' ) {
 
                 if ( $is_keyword_returning_list{$next_nonblank_token} ) {
@@ -12769,7 +12759,7 @@ EOM
         # if we do not see another elseif or an else.
         if ($looking_for_else) {
 
-            unless ( $rLL->[$K_first]->[_TOKEN_] =~ /^(elsif|else)$/ ) {
+            unless ( $rLL->[$K_first_true]->[_TOKEN_] =~ /^(elsif|else)$/ ) {
                 write_logfile_entry("(No else block)\n");
             }
             $looking_for_else = 0;
@@ -13151,7 +13141,10 @@ EOM
 
                 # set string indicating what we need to look for brace follower
                 # tokens
-                if ( $block_type eq 'do' ) {
+                if ( $is_if_unless_elsif_else{$block_type} ) {
+                    $rbrace_follower = undef;
+                }
+                elsif ( $block_type eq 'do' ) {
                     $rbrace_follower = \%is_do_follower;
                     if (
                         $self->tight_paren_follows( $K_to_go[0], $Ktoken_vars )
@@ -13160,13 +13153,6 @@ EOM
                         $rbrace_follower = { ')' => 1 };
                     }
                 }
-                ##elsif ( $block_type =~ /^(if|elsif|unless)$/ ) {
-                elsif ( $is_if_unless_elsif{$block_type} ) {
-                    $rbrace_follower = \%is_if_brace_follower;
-                }
-                elsif ( $block_type eq 'else' ) {
-                    $rbrace_follower = \%is_else_brace_follower;
-                }
 
                 # added eval for borris.t
                 elsif ($is_sort_map_grep_eval{$block_type}