This:
return $outputs->{ $call_key } if defined $outputs->{ $call_key +}; $outputs->{ $call_key } = $self->$orig( @args ); return $outputs->{ $call_key };
Would be more concise like this:
return( $outputs->{$call_key} //= $self->$orig(@args) );
As it's the last line in the sub, you don't even need the return keyword. (And sub calls are slightly optimized if you leave it out.)
One thing to beware: get_method_list doesn't return a list of all methods — it doesn't include inherited methods. You could use get_all_methods (which retuns Moose::Meta::Method objects instead of a list of method names as strings, so you will need to do $_->name on each).
In reply to Re: Proxying (almost) all methods in a class for mass memoization
by tobyink
in thread Proxying (almost) all methods in a class for mass memoization
by Tommy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |