From 21b5028af9adb037b9deb3970167f376e9ffe632 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 20 Oct 2020 17:34:32 -0700 Subject: [PATCH] added speedup filter; made sub scan_list 25% faster --- lib/Perl/Tidy/Formatter.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 801b6935..176eca1c 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -13204,10 +13204,17 @@ sub set_continuation_breaks { } my %is_logical_container; + my %quick_filter; BEGIN { my @q = qw# if elsif unless while and or err not && | || ? : ! #; @is_logical_container{@q} = (1) x scalar(@q); + + # This filter will allow most tokens to skip past a section of code + %quick_filter = %is_assignment; + @q = qw# => . ; < > ~ #; + push @q, ','; + @quick_filter{@q} = (1) x scalar(@q); } sub set_for_semicolon_breakpoints { @@ -14069,6 +14076,9 @@ sub set_continuation_breaks { $current_depth = $depth; + # most token types can skip the rest of this loop + next unless ( $quick_filter{$type} ); + # handle comma-arrow if ( $type eq '=>' ) { next if ( $last_nonblank_type eq '=>' ); -- 2.39.5