From: Jesse Luehrs Date: Sat, 16 Apr 2011 03:29:10 +0000 (-0500) Subject: stop using Memoize, it apparently breaks under mod_perl or something X-Git-Tag: 0.04~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7422523412942c3780bba407c4f16c96f831307d;p=gitmo%2FEval-Closure.git stop using Memoize, it apparently breaks under mod_perl or something --- diff --git a/lib/Eval/Closure.pm b/lib/Eval/Closure.pm index 74b64a4..a610194 100644 --- a/lib/Eval/Closure.pm +++ b/lib/Eval/Closure.pm @@ -9,7 +9,6 @@ use Sub::Exporter -setup => { use Carp; use overload (); -use Memoize; use Scalar::Util qw(reftype); use Try::Tiny; @@ -193,14 +192,23 @@ sub _clean_eval_closure { return ($code, $e); } -sub _make_compiler { - local $@; - local $SIG{__DIE__}; - my $compiler = eval _make_compiler_source(@_); - my $e = $@; - return ($compiler, $e); +{ + my %compiler_cache; + + sub _make_compiler { + my $source = _make_compiler_source(@_); + + unless (exists $compiler_cache{$source}) { + local $@; + local $SIG{__DIE__}; + my $compiler = eval $source; + my $e = $@; + $compiler_cache{$source} = [ $compiler, $e ]; + } + + return @{ $compiler_cache{$source} }; + } } -memoize('_make_compiler'); sub _make_compiler_source { my ($source, @capture_keys) = @_;