diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-03-04 12:59:02 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-03-04 12:59:02 -0600 |
commit | 36cbfbad272906e832c887c1e07a22e21bd3b894 (patch) | |
tree | 009dd26524a8d9e9ca4af9c8ec3abba477d4e16e /lib | |
parent | 55d477cc746d9ef3ad67d27c7b812665822d8cd5 (diff) | |
download | package-stash-36cbfbad272906e832c887c1e07a22e21bd3b894.tar.gz package-stash-36cbfbad272906e832c887c1e07a22e21bd3b894.zip |
disable caching of the namespace on 5.8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Package/Stash/PP.pm | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index 653eeaf..60c486a 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -9,6 +9,9 @@ use Symbol; # before 5.12, assigning to the ISA glob would make it lose its magical ->isa # powers use constant BROKEN_ISA_ASSIGNMENT => ($] < 5.012); +# before 5.10, stashes don't ever seem to drop to a refcount of zero, so +# weakening them isn't helpful +use constant BROKEN_WEAK_STASH => ($] < 5.010); =head1 SYNOPSIS @@ -38,18 +41,23 @@ sub name { sub namespace { confess "Can't call namespace as a class method" unless blessed($_[0]); - return $_[0]->{namespace} if defined $_[0]->{namespace}; - { + if (BROKEN_WEAK_STASH) { no strict 'refs'; - # supposedly this caused a bug in earlier perls, but I can't reproduce - # it, so re-enabling the caching - $_[0]->{namespace} = \%{$_[0]->name . '::'}; + return \%{$_[0]->name . '::'}; } + else { + return $_[0]->{namespace} if defined $_[0]->{namespace}; - weaken($_[0]->{namespace}); + { + no strict 'refs'; + $_[0]->{namespace} = \%{$_[0]->name . '::'}; + } - return $_[0]->{namespace}; + weaken($_[0]->{namespace}); + + return $_[0]->{namespace}; + } } { |