sv.c: Remove redundant Sv[INP]OK checks on fbm/regexps
authorFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 06:51:42 +0000 (23:51 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 09:04:57 +0000 (02:04 -0700)
These two code paths, sv_2iv and sv_2uv, used to be shared with gmag-
ical scalars in general, but now only apply to scalars that cannot
hold numeric values and are always SvPOK.

sv.c

diff --git a/sv.c b/sv.c
index 182bcec..660642f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2282,11 +2282,7 @@ Perl_sv_2iv_flags(pTHX_ register SV *const sv, const I32 flags)
 
           Regexps have no SvIVX and SvNVX fields.
        */
-       if (SvIOKp(sv))
-           return SvIVX(sv);
-       if (SvNOKp(sv))
-           return I_V(SvNVX(sv));
-       if (SvPOKp(sv)) {
+           assert(SvPOKp(sv));
            UV value;
            const int numtype
                = grok_number(SvPVX_const(sv), SvCUR(sv), &value);
@@ -2307,10 +2303,6 @@ Perl_sv_2iv_flags(pTHX_ register SV *const sv, const I32 flags)
                    not_a_number(sv);
            }
            return I_V(Atof(SvPVX_const(sv)));
-       }
-       if (ckWARN(WARN_UNINITIALIZED))
-           report_uninit(sv);
-       return 0;
     }
 
     if (SvTHINKFIRST(sv)) {
@@ -2374,11 +2366,7 @@ Perl_sv_2uv_flags(pTHX_ register SV *const sv, const I32 flags)
        /* FBMs use the space for SvIVX and SvNVX for other purposes, and use
           the same flag bit as SVf_IVisUV, so must not let them cache IVs.  
           Regexps have no SvIVX and SvNVX fields. */
-       if (SvIOKp(sv))
-           return SvUVX(sv);
-       if (SvNOKp(sv))
-           return U_V(SvNVX(sv));
-       if (SvPOKp(sv)) {
+           assert(SvPOKp(sv));
            UV value;
            const int numtype
                = grok_number(SvPVX_const(sv), SvCUR(sv), &value);
@@ -2394,10 +2382,6 @@ Perl_sv_2uv_flags(pTHX_ register SV *const sv, const I32 flags)
                    not_a_number(sv);
            }
            return U_V(Atof(SvPVX_const(sv)));
-       }
-       if (ckWARN(WARN_UNINITIALIZED))
-           report_uninit(sv);
-       return 0;
     }
 
     if (SvTHINKFIRST(sv)) {