From 3b2f8b74cb7a8bc832f92d71b5289798c5b3f22f Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 12 Apr 2022 06:44:15 -0700 Subject: [PATCH] eliminate 2 unused hashes --- lib/Perl/Tidy.pm | 4 ++++ lib/Perl/Tidy/Formatter.pm | 32 +++++++++----------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 9718fa01..d6edcfbe 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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 } } diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index db403dd3..23af9e28 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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} -- 2.39.5