This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/re/fold_grind.t: tidy up a bit
authorDavid Mitchell <davem@iabyn.com>
Wed, 23 Feb 2011 17:47:35 +0000 (17:47 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 23 Feb 2011 22:03:41 +0000 (22:03 +0000)
The previous commit unwrapped an eval; now that the eval's removed,
the code can be tidied up a bit. No functional changes, but it strips
a further few seconds off the execution time.

t/re/fold_grind.t

index e39de5f..d4ca846 100644 (file)
@@ -449,31 +449,37 @@ foreach my $test (sort { numerically } keys %tests) {
                             $op = 0 if $target_has_latin1 && $charset eq 'l' && $both_sides && ( ! $quantifier || $quantifier eq '?') && $parend < 2;
                           }
 
-                          $op = ($op) ? '=~' : '!~';
-
-                          my $debug .= " uni_semantics=$uni_semantics, should_fail=$should_fail, bracketed=$bracketed, prepend=$prepend, append=$append, parend=$parend, quantifier=$quantifier, l_anchor=$l_anchor, r_anchor=$r_anchor";
-                          $debug .= "; pattern_above_latin1=$pattern_above_latin1; utf8_pattern=$utf8_pattern";
                           # XXX Doesn't currently test multi-char folds in pattern
                           next if @pattern != 1;
-                          my $eval = "my \$c = \"$prepend$lhs$append\"; my \$p = qr/$quantified/i;$upgrade_target$upgrade_pattern \$c $op \$p";
+
+                          my $desc = "my \$c = \"$prepend$lhs$append\"; "
+                                   . "my \$p = qr/$quantified/i;"
+                                   . "$upgrade_target$upgrade_pattern "
+                                   . "\$c " . ($op ? "=~" : "!~") . " \$p; ";
+                          if ($DEBUG) {
+                            $desc .= (
+                             "; uni_semantics=$uni_semantics, "
+                             . "should_fail=$should_fail, "
+                             . "bracketed=$bracketed, "
+                             . "prepend=$prepend, "
+                             . "append=$append, "
+                             . "parend=$parend, "
+                             . "quantifier=$quantifier, "
+                             . "l_anchor=$l_anchor, "
+                             . "r_anchor=$r_anchor; "
+                             . "pattern_above_latin1=$pattern_above_latin1; "
+                             . "utf8_pattern=$utf8_pattern"
+                            );
+                          }
+
                           my $c = "$prepend$lhs_str$append";
                           my $p = qr/$quantified/i;
                           utf8::upgrade($c) if length($upgrade_target);
                           utf8::upgrade($p) if length($upgrade_pattern);
-                          my $res;
-                          if ($op eq '=~') {
-                              $res = ($c =~ $p);
-                          }
-                          elsif ($op eq '!~') {
-                              $res = ($c !~ $p);
-                          }
-                          else {
-                              fail("unknown op '$op'");
-                          }
+                          my $res = $op ? ($c =~ $p): ($c !~ $p);
 
-                          $debug = "" unless $DEBUG;
-                         $count++;
-                          ok($res, "$eval; $debug");
+                          $count++;
+                          ok($res, $desc);
                         }
                       }
                     }