disable caching of the namespace on 5.8
Jesse Luehrs [Fri, 4 Mar 2011 19:06:43 +0000 (13:06 -0600)]
XS.xs
t/02-extension.t

diff --git a/XS.xs b/XS.xs
index 73ca16f..a36fd67 100644 (file)
--- 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
 
index 2096221..f8e4752 100644 (file)
@@ -21,6 +21,8 @@ use Test::Fatal;
         return $self;
     }
 
+    sub namespace { shift->{namespace} }
+
     sub add_symbol {
         my ($self, $variable, $initial_value) = @_;