From: Jesse Luehrs Date: Wed, 20 Apr 2011 03:35:47 +0000 (-0500) Subject: don't calculate the cache key unless we're going to be caching X-Git-Tag: 2.0100~217 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4f629382aba0961d666ec1b0b35a083885b95b31;p=gitmo%2FMoose.git don't calculate the cache key unless we're going to be caching --- diff --git a/lib/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index bc5c6ca..d3930ff 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -97,10 +97,13 @@ sub create { my $cache_ok = delete $options{cache}; - my $cache_key = $class->_anon_cache_key(%options); + my $cache_key; + if ($cache_ok) { + $cache_key = $class->_anon_cache_key(%options); - if ($cache_ok && defined $ANON_PACKAGE_CACHE{$cache_key}) { - return $ANON_PACKAGE_CACHE{$cache_key}; + if (defined $ANON_PACKAGE_CACHE{$cache_key}) { + return $ANON_PACKAGE_CACHE{$cache_key}; + } } $options{weaken} = !$cache_ok unless exists $options{weaken};