summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-04-15 22:29:10 -0500
committerJesse Luehrs <doy@tozt.net>2011-04-15 22:29:33 -0500
commit7422523412942c3780bba407c4f16c96f831307d (patch)
tree91940ea29db043d98d26457e88c9e6fa5e818d9c /lib
parentfafdf693f6315e2463444d109c0846dbf9f79dae (diff)
downloadeval-closure-7422523412942c3780bba407c4f16c96f831307d.tar.gz
eval-closure-7422523412942c3780bba407c4f16c96f831307d.zip
stop using Memoize, it apparently breaks under mod_perl or something
Diffstat (limited to 'lib')
-rw-r--r--lib/Eval/Closure.pm24
1 files changed, 16 insertions, 8 deletions
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) = @_;