sv_clear can manipulate the arena array directly too.
[p5sagit/p5-mst-13.2.git] / pp_hot.c
index 7b80467..813b606 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -329,7 +329,7 @@ PP(pp_or)
 PP(pp_defined)
 {
     dSP;
-    register SV* sv;
+    register SV* sv = NULL;
     bool defined = FALSE;
     const int op_type = PL_op->op_type;
 
@@ -344,7 +344,8 @@ PP(pp_defined)
         sv = POPs;
         if (!sv || !SvANY(sv))
             RETPUSHNO;
-    }
+    } else
+        DIE(aTHX_ "panic:  Invalid op (%s) in pp_defined()", OP_NAME(PL_op));
 
     switch (SvTYPE(sv)) {
     case SVt_PVAV:
@@ -371,11 +372,11 @@ PP(pp_defined)
         if(op_type == OP_DOR)
             --SP;
         RETURNOP(cLOGOP->op_other);
-    } else if (op_type == OP_DEFINED) {
-        if(defined) 
-            RETPUSHYES;
-        RETPUSHNO;
     }
+    /* assuming OP_DEFINED */
+    if(defined) 
+        RETPUSHYES;
+    RETPUSHNO;
 }
 
 PP(pp_add)
@@ -793,7 +794,7 @@ PP(pp_rv2av)
        if (SvRMAGICAL(av)) {
            U32 i;
            for (i=0; i < (U32)maxarg; i++) {
-               SV **svp = av_fetch(av, i, FALSE);
+               SV ** const svp = av_fetch(av, i, FALSE);
                /* See note in pp_helem, and bug id #27839 */
                SP[i+1] = svp
                    ? SvGMAGICAL(*svp) ? sv_mortalcopy(*svp) : *svp
@@ -1394,7 +1395,7 @@ yup:                                      /* Confirmed by INTUIT */
        rx->subbeg = (char *) truebase;
        rx->startp[0] = s - truebase;
        if (RX_MATCH_UTF8(rx)) {
-           char *t = (char*)utf8_hop((U8*)s, rx->minlen);
+           char * const t = (char*)utf8_hop((U8*)s, rx->minlen);
            rx->endp[0] = t - truebase;
        }
        else {
@@ -1887,11 +1888,8 @@ PP(pp_iter)
            RETPUSHNO;
 
        if (SvMAGICAL(av) || AvREIFY(av)) {
-           SV **svp = av_fetch(av, cx->blk_loop.iterix--, FALSE);
-           if (svp)
-               sv = *svp;
-           else
-               sv = Nullsv;
+           SV ** const svp = av_fetch(av, cx->blk_loop.iterix--, FALSE);
+           sv = svp ? *svp : Nullsv;
        }
        else {
            sv = AvARRAY(av)[cx->blk_loop.iterix--];
@@ -1903,18 +1901,15 @@ PP(pp_iter)
            RETPUSHNO;
 
        if (SvMAGICAL(av) || AvREIFY(av)) {
-           SV **svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE);
-           if (svp)
-               sv = *svp;
-           else
-               sv = Nullsv;
+           SV ** const svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE);
+           sv = svp ? *svp : Nullsv;
        }
        else {
            sv = AvARRAY(av)[++cx->blk_loop.iterix];
        }
     }
 
-    if (sv && SvREFCNT(sv) == 0) {
+    if (sv && SvIS_FREED(sv)) {
        *itersvp = Nullsv;
        Perl_croak(aTHX_ "Use of freed value in iteration");
     }
@@ -1972,7 +1967,7 @@ PP(pp_subst)
     register REGEXP *rx = PM_GETRE(pm);
     STRLEN len;
     int force_on_match = 0;
-    I32 oldsave = PL_savestack_ix;
+    const I32 oldsave = PL_savestack_ix;
     STRLEN slen;
     bool doutf8 = FALSE;
 #ifdef PERL_OLD_COPY_ON_WRITE
@@ -2570,7 +2565,7 @@ PP(pp_leavesublv)
 STATIC CV *
 S_get_db_sub(pTHX_ SV **svp, CV *cv)
 {
-    SV *dbsv = GvSVn(PL_DBsub);
+    SV * const dbsv = GvSVn(PL_DBsub);
 
     save_item(dbsv);
     if (!PERLDB_SUB_NN) {
@@ -2692,7 +2687,7 @@ PP(pp_entersub)
        /* This path taken at least 75% of the time   */
        dMARK;
        register I32 items = SP - MARK;
-       AV* padlist = CvPADLIST(cv);
+       AV* const padlist = CvPADLIST(cv);
        PUSHBLOCK(cx, CXt_SUB, MARK);
        PUSHSUB(cx);
        cx->blk_sub.retop = PL_op->op_next;
@@ -2710,12 +2705,7 @@ PP(pp_entersub)
        PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
        if (hasargs)
        {
-           AV* av;
-#if 0
-           DEBUG_S(PerlIO_printf(Perl_debug_log,
-                                 "%p entersub preparing @_\n", thr));
-#endif
-           av = (AV*)PAD_SVl(0);
+           AV* const av = (AV*)PAD_SVl(0);
            if (AvREAL(av)) {
                /* @_ is normally not REAL--this should only ever
                 * happen when DB::sub() calls things that modify @_ */
@@ -2883,7 +2873,7 @@ PP(pp_aelem)
     SV** svp;
     SV* const elemsv = POPs;
     IV elem = SvIV(elemsv);
-    AV* av = (AV*)POPs;
+    AV* const av = (AV*)POPs;
     const U32 lval = PL_op->op_flags & OPf_MOD || LVRET;
     const U32 defer = (PL_op->op_private & OPpLVAL_DEFER) && (elem > av_len(av));
     SV *sv;