use Carp;
use overload ();
-use Memoize;
use Scalar::Util qw(reftype);
use Try::Tiny;
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) = @_;