From 7422523412942c3780bba407c4f16c96f831307d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 15 Apr 2011 22:29:10 -0500 Subject: stop using Memoize, it apparently breaks under mod_perl or something --- lib/Eval/Closure.pm | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'lib') 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) = @_; -- cgit v1.2.3-54-g00ecf