From: Steve Hancock Date: Wed, 21 Oct 2020 00:34:32 +0000 (-0700) Subject: added speedup filter; made sub scan_list 25% faster X-Git-Tag: 20201001.03~49 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=21b5028af9adb037b9deb3970167f376e9ffe632;p=perltidy.git added speedup filter; made sub scan_list 25% faster --- 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 '=>' );