From: Jesse Luehrs Date: Thu, 21 Oct 2010 05:15:40 +0000 (-0500) Subject: only pass the keys into _make_compiler X-Git-Tag: 0.01~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=447800b5183d24c554ebb448684d3604925a1a9f;p=gitmo%2FEval-Closure.git only pass the keys into _make_compiler --- diff --git a/lib/Eval/Closure.pm b/lib/Eval/Closure.pm index f90a976..aa0777d 100644 --- a/lib/Eval/Closure.pm +++ b/lib/Eval/Closure.pm @@ -81,10 +81,11 @@ sub _clean_eval_closure { _dump_source(_make_compiler_source(@_)); } - my ($compiler, $e) = _make_compiler(@_); + my @capture_keys = keys %$captures; + my ($compiler, $e) = _make_compiler($source, @capture_keys); my $code; if (defined $compiler) { - $code = $compiler->(map { $captures->{$_} } sort keys %$captures); + $code = $compiler->(@$captures{@capture_keys}); } if (defined($code) && (!ref($code) || ref($code) ne 'CODE')) { @@ -105,13 +106,13 @@ sub _make_compiler { } sub _make_compiler_source { - my ($source, $captures) = @_; + my ($source, @capture_keys) = @_; my $i = 0; return join "\n", ( 'sub {', (map { 'my ' . $_ . ' = ' . substr($_, 0, 1) . '{$_[' . $i++ . ']};' - } sort keys %$captures), + } @capture_keys), $source, '}', );