This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Simplify the SvGMAGIC code in sv_2nv, removing duplicated checks to
authorNicholas Clark <nick@ccl4.org>
Wed, 14 Dec 2005 14:08:24 +0000 (14:08 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 14 Dec 2005 14:08:24 +0000 (14:08 +0000)
warn for uninitialized values.

p4raw-id: //depot/perl@26353

sv.c

diff --git a/sv.c b/sv.c
index 30193b0..8ba8eb0 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2054,20 +2054,17 @@ Perl_sv_2nv(pTHX_ register SV *sv)
                return (NV)SvUVX(sv);
            else
                return (NV)SvIVX(sv);
-       }       
-        if (!SvROK(sv)) {
-           if (!(SvFLAGS(sv) & SVs_PADTMP)) {
-               if (!PL_localizing && ckWARN(WARN_UNINITIALIZED))
-                   report_uninit(sv);
-           }
-            return (NV)0;
-        }
-       /* 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,numer)) &&
                 (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv))))
              return SvNV(tmpstr);