]> git.donarmstrong.com Git - perltidy.git/commitdiff
minor speedup
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 7 Nov 2020 00:09:23 +0000 (16:09 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 7 Nov 2020 00:09:23 +0000 (16:09 -0800)
lib/Perl/Tidy/Formatter.pm

index 55718379943fbe11f4b4b0252626b975c0165a5c..98cf934e156756f89c152076acf9f97f73820a61 100644 (file)
@@ -10269,6 +10269,18 @@ EOM
     my @unmatched_opening_indexes_in_this_batch;
     my @unmatched_closing_indexes_in_this_batch;
     my %comma_arrow_count;
+    my %is_opening_tok = (
+        '(' => 1,
+        '[' => 1,
+        '{' => 1,
+        '?' => 1
+    );
+    my %is_closing_tok = (
+        ')' => 1,
+        ']' => 1,
+        '}' => 1,
+        ':' => 1
+    );
 
     sub initialize_saved_opening_indentation {
         %saved_opening_indentation = ();
@@ -10301,10 +10313,10 @@ EOM
         foreach my $i ( 0 .. $max_index_to_go ) {
             if ( $type_sequence_to_go[$i] ) {
                 my $token = $tokens_to_go[$i];
-                if ( $token =~ /^[\(\[\{\?]$/ ) {
+                if ( $is_opening_tok{$token} ) {
                     push @unmatched_opening_indexes_in_this_batch, $i;
                 }
-                elsif ( $token =~ /^[\)\]\}\:]$/ ) {
+                elsif ( $is_closing_tok{$token} ) {
 
                     my $i_mate = pop @unmatched_opening_indexes_in_this_batch;
                     if ( defined($i_mate) && $i_mate >= 0 ) {