Simplify the expression for the upgrade logic for SVt_IV.
Nicholas Clark [Fri, 18 Nov 2005 11:20:10 +0000 (11:20 +0000)]
Replace the "can't happen" comment for SVt_PVIV with assertions
that it didn't happen.

p4raw-id: //depot/perl@26158

sv.c

diff --git a/sv.c b/sv.c
index e7355b7..fdd9a65 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -1460,10 +1460,10 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type)
     case SVt_NULL:
        break;
     case SVt_IV:
-       if (new_type == SVt_NV)
-           new_type = SVt_PVNV;
-       else if (new_type < SVt_PVIV)
-           new_type = SVt_PVIV;
+       if (new_type < SVt_PVIV) {
+           new_type = (new_type == SVt_NV)
+               ? SVt_PVNV : SVt_PVIV;
+       }
        break;
     case SVt_NV:
        if (new_type < SVt_PVNV)
@@ -1580,9 +1580,8 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type)
        new_body_arenaroot = &PL_body_arenaroots[SVt_PVIV];
        /* XXX Is this still needed?  Was it ever needed?   Surely as there is
           no route from NV to PVIV, NOK can never be true  */
-       if (SvNIOK(sv))
-           (void)SvIOK_on(sv);
-       SvNOK_off(sv);
+       assert(!SvNOKp(sv));
+       assert(!SvNOK(sv));
        goto new_body_no_NV; 
     case SVt_PV:
        new_body_offset = - bodies_by_type[SVt_PV].offset;