From: Rick Delaney Date: Mon, 22 Aug 2005 13:00:33 +0000 (-0400) Subject: Use SvGETMAGIC more often X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5b295bef27e91243a93cdb460dcf005e5bf35426;p=p5sagit%2Fp5-mst-13.2.git Use SvGETMAGIC more often Message-ID: <20050822170033.GH7674@localhost.localdomain> p4raw-id: //depot/perl@25322 --- diff --git a/doio.c b/doio.c index 91ef7a2..4f30a59 100644 --- a/doio.c +++ b/doio.c @@ -1308,8 +1308,7 @@ Perl_do_print(pTHX_ register SV *sv, PerlIO *fp) return TRUE; case SVt_IV: if (SvIOK(sv)) { - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvIsUV(sv)) PerlIO_printf(fp, "%"UVuf, (UV)SvUVX(sv)); else diff --git a/pp.c b/pp.c index 15083bc..e8bafac 100644 --- a/pp.c +++ b/pp.c @@ -505,8 +505,8 @@ PP(pp_ref) const char *pv; SV * const sv = POPs; - if (sv && SvGMAGICAL(sv)) - mg_get(sv); + if (sv) + SvGETMAGIC(sv); if (!sv || !SvROK(sv)) RETPUSHNO; @@ -755,8 +755,7 @@ PP(pp_defined) RETPUSHYES; break; default: - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvOK(sv)) RETPUSHYES; } @@ -1384,8 +1383,7 @@ PP(pp_repeat) { register IV count; dPOPss; - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvIOKp(sv)) { if (SvUOK(sv)) { const UV uv = SvUV(sv); @@ -2223,8 +2221,8 @@ PP(pp_bit_and) dSP; dATARGET; tryAMAGICbin(band,opASSIGN); { dPOPTOPssrl; - if (SvGMAGICAL(left)) mg_get(left); - if (SvGMAGICAL(right)) mg_get(right); + SvGETMAGIC(left); + SvGETMAGIC(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { const IV i = SvIV_nomg(left) & SvIV_nomg(right); @@ -2248,8 +2246,8 @@ PP(pp_bit_xor) dSP; dATARGET; tryAMAGICbin(bxor,opASSIGN); { dPOPTOPssrl; - if (SvGMAGICAL(left)) mg_get(left); - if (SvGMAGICAL(right)) mg_get(right); + SvGETMAGIC(left); + SvGETMAGIC(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right); @@ -2273,8 +2271,8 @@ PP(pp_bit_or) dSP; dATARGET; tryAMAGICbin(bor,opASSIGN); { dPOPTOPssrl; - if (SvGMAGICAL(left)) mg_get(left); - if (SvGMAGICAL(right)) mg_get(right); + SvGETMAGIC(left); + SvGETMAGIC(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right); @@ -2299,8 +2297,7 @@ PP(pp_negate) { dTOPss; const int flags = SvFLAGS(sv); - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) { /* It's publicly an integer, or privately an integer-not-float */ oops_its_an_int: @@ -2376,8 +2373,7 @@ PP(pp_complement) dSP; dTARGET; tryAMAGICun(compl); { dTOPss; - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvNIOKp(sv)) { if (PL_op->op_private & HINT_INTEGER) { const IV i = ~SvIV_nomg(sv); diff --git a/pp_ctl.c b/pp_ctl.c index 3952a4a..2493fa8 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1126,10 +1126,8 @@ PP(pp_flop) if (GIMME == G_ARRAY) { dPOPPOPssrl; - if (SvGMAGICAL(left)) - mg_get(left); - if (SvGMAGICAL(right)) - mg_get(right); + SvGETMAGIC(left); + SvGETMAGIC(right); if (RANGE_IS_NUMERIC(left,right)) { register IV i, j; @@ -1543,8 +1541,7 @@ PP(pp_dorassign) RETURN; break; default: - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvOK(sv)) RETURN; } diff --git a/pp_hot.c b/pp_hot.c index 8298026..72f657d 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -169,8 +169,7 @@ PP(pp_concat) } else { /* TARG == left */ STRLEN llen; - if (SvGMAGICAL(left)) - mg_get(left); /* or mg_get(left) may happen here */ + SvGETMAGIC(left); /* or mg_get(left) may happen here */ if (!SvOK(TARG)) sv_setpvn(left, "", 0); (void)SvPV_nomg_const(left, llen); /* Needed to set UTF8 flag */ @@ -350,8 +349,7 @@ PP(pp_dor) RETURN; break; default: - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvOK(sv)) RETURN; } @@ -2914,8 +2912,7 @@ PP(pp_aelem) void Perl_vivify_ref(pTHX_ SV *sv, U32 to_what) { - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (!SvOK(sv)) { if (SvREADONLY(sv)) Perl_croak(aTHX_ PL_no_modify); @@ -2985,8 +2982,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) if (!sv) Perl_croak(aTHX_ "Can't call method \"%s\" on an undefined value", name); - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvROK(sv)) ob = (SV*)SvRV(sv); else { diff --git a/sv.c b/sv.c index 70b2740..88c864b 100644 --- a/sv.c +++ b/sv.c @@ -3443,8 +3443,7 @@ sv_true() or its macro equivalent. bool Perl_sv_2bool(pTHX_ register SV *sv) { - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (!SvOK(sv)) return 0; @@ -6877,8 +6876,7 @@ Perl_sv_inc(pTHX_ register SV *sv) if (!sv) return; - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvTHINKFIRST(sv)) { if (SvIsCOW(sv)) sv_force_normal_flags(sv, 0); @@ -7033,8 +7031,7 @@ Perl_sv_dec(pTHX_ register SV *sv) if (!sv) return; - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvTHINKFIRST(sv)) { if (SvIsCOW(sv)) sv_force_normal_flags(sv, 0); @@ -7687,8 +7684,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **st, GV **gvp, I32 lref) goto fix_gv; default: - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (SvROK(sv)) { SV **sp = &sv; /* Used in tryAMAGICunDEREF macro. */ tryAMAGICunDEREF(to_cv); @@ -8121,8 +8117,7 @@ Perl_sv_isobject(pTHX_ SV *sv) { if (!sv) return 0; - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (!SvROK(sv)) return 0; sv = (SV*)SvRV(sv); @@ -8147,8 +8142,7 @@ Perl_sv_isa(pTHX_ SV *sv, const char *name) const char *hvname; if (!sv) return 0; - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (!SvROK(sv)) return 0; sv = (SV*)SvRV(sv); diff --git a/universal.c b/universal.c index 4506f77..0c29d93 100644 --- a/universal.c +++ b/universal.c @@ -144,8 +144,7 @@ Perl_sv_derived_from(pTHX_ SV *sv, const char *name) HV *stash = Nullhv; HV *name_stash; - if (SvGMAGICAL(sv)) - mg_get(sv) ; + SvGETMAGIC(sv); if (SvROK(sv)) { sv = SvRV(sv); @@ -262,8 +261,7 @@ XS(XS_UNIVERSAL_isa) sv = ST(0); - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)) || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv)))) @@ -288,8 +286,7 @@ XS(XS_UNIVERSAL_can) sv = ST(0); - if (SvGMAGICAL(sv)) - mg_get(sv); + SvGETMAGIC(sv); if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)) || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv)))) diff --git a/xsutils.c b/xsutils.c index b22a263..848fc95 100644 --- a/xsutils.c +++ b/xsutils.c @@ -305,8 +305,7 @@ usage: rv = ST(0); ST(0) = TARG; - if (SvGMAGICAL(rv)) - mg_get(rv); + SvGETMAGIC(rv); if (!(SvOK(rv) && SvROK(rv))) goto usage; sv = SvRV(rv);