Upgrade to Time::HiRes 1.9715
[p5sagit/p5-mst-13.2.git] / mro.c
diff --git a/mro.c b/mro.c
index 5f9bcfe..2d52805 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -54,7 +54,7 @@ Perl_mro_meta_init(pTHX_ HV* stash)
 {
     struct mro_meta* newmeta;
 
-    assert(stash);
+    PERL_ARGS_ASSERT_MRO_META_INIT;
     assert(HvAUX(stash));
     assert(!(HvAUX(stash)->xhv_mro_meta));
     Newxz(newmeta, 1, struct mro_meta);
@@ -74,7 +74,7 @@ Perl_mro_meta_dup(pTHX_ struct mro_meta* smeta, CLONE_PARAMS* param)
 {
     struct mro_meta* newmeta;
 
-    assert(smeta);
+    PERL_ARGS_ASSERT_MRO_META_DUP;
 
     Newx(newmeta, 1, struct mro_meta);
     Copy(smeta, newmeta, 1, struct mro_meta);
@@ -120,7 +120,7 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level)
     const HEK* stashhek;
     struct mro_meta* meta;
 
-    assert(stash);
+    PERL_ARGS_ASSERT_MRO_GET_LINEAR_ISA_DFS;
     assert(HvAUX(stash));
 
     stashhek = HvNAME_HEK(stash);
@@ -234,7 +234,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level)
     const HEK* stashhek;
     struct mro_meta* meta;
 
-    assert(stash);
+    PERL_ARGS_ASSERT_MRO_GET_LINEAR_ISA_C3;
     assert(HvAUX(stash));
 
     stashhek = HvNAME_HEK(stash);
@@ -447,7 +447,7 @@ Perl_mro_get_linear_isa(pTHX_ HV *stash)
 {
     struct mro_meta* meta;
 
-    assert(stash);
+    PERL_ARGS_ASSERT_MRO_GET_LINEAR_ISA;
     if(!SvOOK(stash))
         Perl_croak(aTHX_ "Can't linearize anonymous symbol table");
 
@@ -481,6 +481,8 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash)
     const char * const stashname = HvNAME_get(stash);
     const STRLEN stashname_len = HvNAMELEN_get(stash);
 
+    PERL_ARGS_ASSERT_MRO_ISA_CHANGED_IN;
+
     if(!stashname)
         Perl_croak(aTHX_ "Can't call mro_isa_changed_in() on anonymous symbol table");
 
@@ -554,19 +556,12 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash)
         HE *he = hv_fetch_ent(PL_isarev, sv, TRUE, 0);
 
        /* That fetch should not fail.  But if it had to create a new SV for
-          us, then we can detect it, because it will not be the correct type.
-          Probably faster and cleaner for us to free that scalar [very little
-          code actually executed to free it] and create a new HV than to
-          copy&paste [SIN!] the code from newHV() to allow us to upgrade the
-          new SV from SVt_NULL.  */
+          us, then will need to upgrade it to an HV (which sv_upgrade() can
+          now do for us. */
 
         mroisarev = (HV*)HeVAL(he);
 
-       if(SvTYPE(mroisarev) != SVt_PVHV) {
-           SvREFCNT_dec(mroisarev);
-           mroisarev = newHV();
-           HeVAL(he) = (SV *)mroisarev;
-        }
+       SvUPGRADE((SV*)mroisarev, SVt_PVHV);
 
        /* This hash only ever contains PL_sv_yes. Storing it over itself is
           almost as cheap as calling hv_exists, so on aggregate we expect to
@@ -625,6 +620,8 @@ Perl_mro_method_changed_in(pTHX_ HV *stash)
     SV ** const svp = hv_fetch(PL_isarev, stashname, stashname_len, 0);
     HV * const isarev = svp ? (HV*)*svp : NULL;
 
+    PERL_ARGS_ASSERT_MRO_METHOD_CHANGED_IN;
+
     if(!stashname)
         Perl_croak(aTHX_ "Can't call mro_method_changed_in() on anonymous symbol table");
 
@@ -829,7 +826,7 @@ XS(XS_mro_get_isarev)
         while((iter = hv_iternext(isarev)))
             av_push(ret_array, newSVsv(hv_iterkeysv(iter)));
     }
-    XPUSHs(sv_2mortal(newRV_noinc((SV*)ret_array)));
+    mXPUSHs(newRV_noinc((SV*)ret_array));
 
     PUTBACK;
     return;
@@ -919,9 +916,7 @@ XS(XS_mro_get_pkg_gen)
 
     SP -= items;
 
-    XPUSHs(sv_2mortal(newSViv(
-        class_stash ? HvMROMETA(class_stash)->pkg_gen : 0
-    )));
+    mXPUSHi(class_stash ? HvMROMETA(class_stash)->pkg_gen : 0);
     
     PUTBACK;
     return;
@@ -959,7 +954,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);
 
@@ -1048,7 +1043,7 @@ XS(XS_mro_nextcan)
                    Perl_croak(aTHX_ "No next::method '%s' found for %s", subname, hvname);
                 XSRETURN_EMPTY;
            }
-           XPUSHs(sv_2mortal(newRV_inc(val)));
+           mXPUSHs(newRV_inc(val));
             XSRETURN(1);
        }
     }
@@ -1056,7 +1051,7 @@ XS(XS_mro_nextcan)
     /* beyond here is just for cache misses, so perf isn't as critical */
 
     stashname_len = subname - fq_subname - 2;
-    stashname = sv_2mortal(newSVpvn(fq_subname, stashname_len));
+    stashname = newSVpvn_flags(fq_subname, stashname_len, SVs_TEMP);
 
     linear_av = mro_get_linear_isa_c3(selfstash, 0); /* has ourselves at the top of the list */
 
@@ -1109,7 +1104,7 @@ XS(XS_mro_nextcan)
             if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) {
                 SvREFCNT_inc_simple_void_NN((SV*)cand_cv);
                 (void)hv_store_ent(nmcache, newSVsv(sv), (SV*)cand_cv, 0);
-                XPUSHs(sv_2mortal(newRV_inc((SV*)cand_cv)));
+                mXPUSHs(newRV_inc((SV*)cand_cv));
                 XSRETURN(1);
             }
         }