X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=mro.c;h=77112e1acdb84c5a9af757d8bfd449da3bddb582;hb=d2aeed1648166d254ac68525c35b77dec4ba8772;hp=95e0ef1d04734131070f68cf4aaf0578e0ef26a8;hpb=117b69cacbec1246787bb24c539676f92ee1c4c7;p=p5sagit%2Fp5-mst-13.2.git diff --git a/mro.c b/mro.c index 95e0ef1..77112e1 100644 --- a/mro.c +++ b/mro.c @@ -518,8 +518,9 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash) if(isarev) { hv_iterinit(isarev); while((iter = hv_iternext(isarev))) { - SV* const revkey = hv_iterkeysv(iter); - HV* revstash = gv_stashsv(revkey, 0); + I32 len; + const char* const revkey = hv_iterkey(iter, &len); + HV* revstash = gv_stashpvn(revkey, len, 0); struct mro_meta* revmeta; if(!revstash) continue; @@ -553,19 +554,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 @@ -645,8 +639,9 @@ Perl_mro_method_changed_in(pTHX_ HV *stash) hv_iterinit(isarev); while((iter = hv_iternext(isarev))) { - SV* const revkey = hv_iterkeysv(iter); - HV* const revstash = gv_stashsv(revkey, 0); + I32 len; + const char* const revkey = hv_iterkey(iter, &len); + HV* const revstash = gv_stashpvn(revkey, len, 0); struct mro_meta* mrometa; if(!revstash) continue; @@ -827,7 +822,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; @@ -917,9 +912,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; @@ -1046,7 +1039,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); } } @@ -1054,7 +1047,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 */ @@ -1107,7 +1100,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); } }