Skip another file in the VERSION comparison program
[p5sagit/p5-mst-13.2.git] / mro.c
diff --git a/mro.c b/mro.c
index 83872dc..ffb72ab 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -185,9 +185,32 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level)
            }
            while(subrv_items--) {
                SV *const subsv = *subrv_p++;
-               if(!hv_exists_ent(stored, subsv, 0)) {
-                   (void)hv_store_ent(stored, subsv, &PL_sv_undef, 0);
-                   av_push(retval, newSVsv(subsv));
+               /* LVALUE fetch will create a new undefined SV if necessary
+                */
+               HE *const he = hv_fetch_ent(stored, subsv, 1, 0);
+               assert(he);
+               if(HeVAL(he) != &PL_sv_undef) {
+                   /* It was newly created.  Steal it for our new SV, and
+                      replace it in the hash with the "real" thing.  */
+                   SV *const val = HeVAL(he);
+                   HEK *const key = HeKEY_hek(he);
+
+                   HeVAL(he) = &PL_sv_undef;
+                   /* Save copying by making a shared hash key scalar. We
+                      inline this here rather than calling Perl_newSVpvn_share
+                      because we already have the scalar, and we already have
+                      the hash key.  */
+                   assert(SvTYPE(val) == SVt_NULL);
+                   sv_upgrade(val, SVt_PV);
+                   SvPV_set(val, HEK_KEY(share_hek_hek(key)));
+                   SvCUR_set(val, HEK_LEN(key));
+                   SvREADONLY_on(val);
+                   SvFAKE_on(val);
+                   SvPOK_on(val);
+                   if (HEK_UTF8(key))
+                       SvUTF8_on(val);
+
+                   av_push(retval, val);
                }
             }
         }
@@ -707,10 +730,8 @@ XS(XS_mro_get_linear_isa) {
     HV* class_stash;
     SV* classname;
 
-    PERL_UNUSED_ARG(cv);
-
     if(items < 1 || items > 2)
-       Perl_croak(aTHX_ "Usage: mro::get_linear_isa(classname [, type ])");
+       croak_xs_usage(cv, "classname [, type ]");
 
     classname = ST(0);
     class_stash = gv_stashsv(classname, 0);
@@ -748,10 +769,8 @@ XS(XS_mro_set_mro)
     HV* class_stash;
     struct mro_meta* meta;
 
-    PERL_UNUSED_ARG(cv);
-
     if (items != 2)
-       Perl_croak(aTHX_ "Usage: mro::set_mro(classname, type)");
+       croak_xs_usage(cv, "classname, type");
 
     classname = ST(0);
     whichstr = SvPV_nolen(ST(1));
@@ -783,10 +802,8 @@ XS(XS_mro_get_mro)
     SV* classname;
     HV* class_stash;
 
-    PERL_UNUSED_ARG(cv);
-
     if (items != 1)
-       Perl_croak(aTHX_ "Usage: mro::get_mro(classname)");
+       croak_xs_usage(cv, "classname");
 
     classname = ST(0);
     class_stash = gv_stashsv(classname, 0);
@@ -806,10 +823,8 @@ XS(XS_mro_get_isarev)
     HV* isarev;
     AV* ret_array;
 
-    PERL_UNUSED_ARG(cv);
-
     if (items != 1)
-       Perl_croak(aTHX_ "Usage: mro::get_isarev(classname)");
+       croak_xs_usage(cv, "classname");
 
     classname = ST(0);
 
@@ -842,10 +857,8 @@ XS(XS_mro_is_universal)
     STRLEN classname_len;
     HE* he;
 
-    PERL_UNUSED_ARG(cv);
-
     if (items != 1)
-       Perl_croak(aTHX_ "Usage: mro::is_universal(classname)");
+       croak_xs_usage(cv, "classname");
 
     classname = ST(0);
 
@@ -866,10 +879,8 @@ XS(XS_mro_invalidate_method_caches)
     dVAR;
     dXSARGS;
 
-    PERL_UNUSED_ARG(cv);
-
     if (items != 0)
-        Perl_croak(aTHX_ "Usage: mro::invalidate_all_method_caches()");
+       croak_xs_usage(cv, "");
 
     PL_sub_generation++;
 
@@ -883,10 +894,8 @@ XS(XS_mro_method_changed_in)
     SV* classname;
     HV* class_stash;
 
-    PERL_UNUSED_ARG(cv);
-
     if(items != 1)
-        Perl_croak(aTHX_ "Usage: mro::method_changed_in(classname)");
+       croak_xs_usage(cv, "classname");
     
     classname = ST(0);
 
@@ -905,10 +914,8 @@ XS(XS_mro_get_pkg_gen)
     SV* classname;
     HV* class_stash;
 
-    PERL_UNUSED_ARG(cv);
-
     if(items != 1)
-        Perl_croak(aTHX_ "Usage: mro::get_pkg_gen(classname)");
+       croak_xs_usage(cv, "classname");
     
     classname = ST(0);
 
@@ -954,7 +961,7 @@ XS(XS_mro_nextcan)
     if(sv_isobject(self))
         selfstash = SvSTASH(SvRV(self));
     else
-        selfstash = gv_stashsv(self, 0);
+        selfstash = gv_stashsv(self, GV_ADD);
 
     assert(selfstash);