From 09409a3c1a87506c94dfdc434c03bc6de0cbf6b5 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 4 Nov 2020 16:07:39 -0800 Subject: [PATCH] minor speedup --- lib/Perl/Tidy/Tokenizer.pm | 12 ++++++++---- lib/Perl/Tidy/VerticalAligner.pm | 18 +++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index f1d4af1b..ab9803c5 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -2843,17 +2843,21 @@ sub prepare_for_a_new_file { chomp $input_line; + # Set a flag to indicate if we might be at an __END__ or __DATA__ line + # This will be used below to avoid quoting a bare word followed by + # a fat comma. + my $is_END_or_DATA; + # trim start of this line unless we are continuing a quoted line # do not trim end because we might end in a quote (test: deken4.pl) # Perl::Tidy::Formatter will delete needless trailing blanks unless ( $in_quote && ( $quote_type eq 'Q' ) ) { $input_line =~ s/^\s+//; # trim left end + + $is_END_or_DATA = substr( $input_line, 0, 1 ) eq '_' + && $input_line =~ /^\s*__(END|DATA)__\s*$/; } - # Set a flag to indicate if we might be at an __END__ or __DATA__ line - # This will be used below to avoid quoting a bare word followed by - # a fat comma. - my $is_END_or_DATA = $input_line =~ /^\s*__(END|DATA)__\s*$/; # update the copy of the line for use in error messages # This must be exactly what we give the pre_tokenizer diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index e23920b4..0e5da7ff 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -3984,15 +3984,15 @@ sub get_output_line_number { # and closing tokens. ############################################################### - my ( $self, $rinput_hash ) = @_; - - my $leading_space_count = $rinput_hash->{leading_space_count}; - my $str = $rinput_hash->{line}; - my $str_length = $rinput_hash->{line_length}; - my $side_comment_length = $rinput_hash->{side_comment_length}; - my $outdent_long_lines = $rinput_hash->{outdent_long_lines}; - my $rvertical_tightness_flags = $rinput_hash->{rvertical_tightness_flags}; - my $level = $rinput_hash->{level}; + my ( $self, $rinput ) = @_; + + my $leading_space_count = $rinput->{leading_space_count}; + my $str = $rinput->{line}; + my $str_length = $rinput->{line_length}; + my $side_comment_length = $rinput->{side_comment_length}; + my $outdent_long_lines = $rinput->{outdent_long_lines}; + my $rvertical_tightness_flags = $rinput->{rvertical_tightness_flags}; + my $level = $rinput->{level}; my $last_level_written = $self->[_last_level_written_]; -- 2.39.5