From: Nicholas Clark Date: Wed, 14 Dec 2005 14:59:18 +0000 (+0000) Subject: Simplify the SvGMAGIC code in sv_[ipu]v_flags. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c7ff15ea62f0cb57f76bc4b2a270c075f724f44;p=p5sagit%2Fp5-mst-13.2.git Simplify the SvGMAGIC code in sv_[ipu]v_flags. p4raw-id: //depot/perl@26354 --- diff --git a/sv.c b/sv.c index 8ba8eb0..199b8df 100644 --- a/sv.c +++ b/sv.c @@ -1910,18 +1910,15 @@ Perl_sv_2iv_flags(pTHX_ register SV *sv, I32 flags) } return I_V(Atof(SvPVX_const(sv))); } - if (!SvROK(sv)) { - if (!(SvFLAGS(sv) & SVs_PADTMP)) { - if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) - report_uninit(sv); - } - return 0; + if (SvROK(sv)) { + goto return_rok; } - /* Else this will drop through into the SvROK case just below, which - will return within the {} for all code paths. */ + assert(SvTYPE(sv) >= SVt_PVMG); + /* This falls through to the report_uninit inside S_sv_2iuv_common. */ } if (SvTHINKFIRST(sv)) { if (SvROK(sv)) { + return_rok: if (SvAMAGIC(sv)) { SV * const tmpstr=AMG_CALLun(sv,numer); if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { @@ -1987,19 +1984,16 @@ Perl_sv_2uv_flags(pTHX_ register SV *sv, I32 flags) } return U_V(Atof(SvPVX_const(sv))); } - if (!SvROK(sv)) { - if (!(SvFLAGS(sv) & SVs_PADTMP)) { - if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) - report_uninit(sv); - } - return 0; + if (SvROK(sv)) { + goto return_rok; } - /* Else this will drop through into the SvROK case just below, which - will return within the {} for all code paths. */ + assert(SvTYPE(sv) >= SVt_PVMG); + /* This falls through to the report_uninit inside S_sv_2iuv_common. */ } if (SvTHINKFIRST(sv)) { if (SvROK(sv)) { SV* tmpstr; + return_rok: if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,numer)) && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) return SvUV(tmpstr); @@ -2412,22 +2406,17 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags) return memcpy(s, tbuf, len + 1); } } - if (!SvROK(sv)) { - if (!(SvFLAGS(sv) & SVs_PADTMP)) { - if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) - report_uninit(sv); - } - if (lp) - *lp = 0; - return (char *)""; - } - /* Else this will drop through into the SvROK case just below, which - will return within the {} for all code paths. */ - } - if (SvTHINKFIRST(sv)) { + if (SvROK(sv)) { + goto return_rok; + } + assert(SvTYPE(sv) >= SVt_PVMG); + /* This falls through to the report_uninit near the end of the + function. */ + } else if (SvTHINKFIRST(sv)) { if (SvROK(sv)) { SV* tmpstr; + return_rok: if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,string)) && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { /* Unwrap this: */