From: Vincent Pit Date: Sun, 9 Sep 2012 09:31:57 +0000 (+0200) Subject: Do less function calls in Scope::Upper::TestGenerator::gen() X-Git-Tag: v0.20~20 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=95dcbf868547141c0b022c55cf8e79498edf12d9;p=perl%2Fmodules%2FScope-Upper.git Do less function calls in Scope::Upper::TestGenerator::gen() --- diff --git a/t/lib/Scope/Upper/TestGenerator.pm b/t/lib/Scope/Upper/TestGenerator.pm index 0b3a8e6..8415632 100644 --- a/t/lib/Scope/Upper/TestGenerator.pm +++ b/t/lib/Scope/Upper/TestGenerator.pm @@ -51,25 +51,37 @@ sub _block { sub gen { my ($height, $level, $i, $x) = @_; - push @_, $i = 0 if @_ == 2; + + if (@_ == 2) { + $i = 0; + push @_, $i; + } + return $call->(@_) if $height < $i; + my @res; my @blks = $allblocks ? @blocks : _block(@_); + my $up = gen($height, $level, $i + 1, $x); + my $t = $test->(@_); + my $loct = $local_test->(@_); for my $base (@$up) { for my $blk (@blks) { - push @res, $blk->[0] . $base . $test->(@_) . $local_test->(@_) . $blk->[1]; + push @res, join '', $blk->[0], $base, $t, $loct, $blk->[1]; } } - $_[3] = $i + 1; - $up = gen($height, $level, $i + 1, $i + 1); + + $_[3] = $x = $i + 1; + $up = gen($height, $level, $i + 1, $x); + $t = $test->(@_); + my $locd = $local_decl->(@_); + $loct = $local_test->(@_); for my $base (@$up) { for my $blk (@blks) { - push @res, $blk->[0] . - $local_decl->(@_) . $base . $test->(@_) . $local_test->(@_) - . $blk->[1]; + push @res, join '', $blk->[0], $locd, $base, $t, $loct, $blk->[1]; } } + return \@res; }