From: Jesse Luehrs Date: Fri, 4 Mar 2011 19:06:43 +0000 (-0600) Subject: disable caching of the namespace on 5.8 X-Git-Tag: 0.22~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c3b261c80f79042f3867cd99c5ba096987886bd;p=gitmo%2FPackage-Stash-XS.git disable caching of the namespace on 5.8 --- diff --git a/XS.xs b/XS.xs index 73ca16f..a36fd67 100644 --- a/XS.xs +++ b/XS.xs @@ -385,16 +385,21 @@ namespace(self) SV *self PREINIT: HE *slot; + SV *package_name; CODE: if (!sv_isobject(self)) croak("Can't call namespace as a class method"); +#if PERL_VERSION < 10 + package_name = _get_name(self); + RETVAL = newRV_inc((SV*)gv_stashpv(SvPV_nolen(package_name), GV_ADD)); +#else slot = hv_fetch_ent((HV*)SvRV(self), namespace_key, 0, namespace_hash); if (slot) { RETVAL = SvREFCNT_inc_simple_NN(HeVAL(slot)); } else { HV *namespace; - SV *nsref, *package_name; + SV *nsref; package_name = _get_name(self); namespace = gv_stashpv(SvPV_nolen(package_name), GV_ADD); @@ -407,6 +412,7 @@ namespace(self) } RETVAL = SvREFCNT_inc_simple_NN(nsref); } +#endif OUTPUT: RETVAL diff --git a/t/02-extension.t b/t/02-extension.t index 2096221..f8e4752 100644 --- a/t/02-extension.t +++ b/t/02-extension.t @@ -21,6 +21,8 @@ use Test::Fatal; return $self; } + sub namespace { shift->{namespace} } + sub add_symbol { my ($self, $variable, $initial_value) = @_;