]> git.donarmstrong.com Git - perltidy.git/commitdiff
added speedup filter; made sub scan_list 25% faster
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 21 Oct 2020 00:34:32 +0000 (17:34 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 21 Oct 2020 00:34:32 +0000 (17:34 -0700)
lib/Perl/Tidy/Formatter.pm

index 801b693538cdc41ade67dacb661b83a5064584fe..176eca1c4c492c24f1666c514c9992c2c30cbd3c 100644 (file)
@@ -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 '=>' );