SvREFCNT_dec already checks if the SV is non-NULL (continued)
Vincent Pit [Sun, 8 Nov 2009 14:48:07 +0000 (15:48 +0100)]
doop.c
hv.c
mg.c
perlio.c
pp.c
pp_sys.c
regcomp.c
regexec.c
scope.c

diff --git a/doop.c b/doop.c
index 3a5967d..c43ecb1 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -1191,8 +1191,7 @@ Perl_do_chomp(pTHX_ register SV *sv)
     }
   nope:
 
-    if (svrecode)
-        SvREFCNT_dec(svrecode);
+    SvREFCNT_dec(svrecode);
 
     Safefree(temp_buffer);
     return count;
diff --git a/hv.c b/hv.c
index fab9c99..cabaac7 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -2149,8 +2149,7 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags)
                 HeSVKEY_set(entry, SvREFCNT_inc_simple_NN(key));
                 return entry;               /* beware, hent_val is not set */
             }
-            if (HeVAL(entry))
-                SvREFCNT_dec(HeVAL(entry));
+            SvREFCNT_dec(HeVAL(entry));
             Safefree(HeKEY_hek(entry));
             del_HE(entry);
             iter->xhv_eiter = NULL; /* HvEITER(hv) = NULL */
diff --git a/mg.c b/mg.c
index aaed62d..f7d3634 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1525,8 +1525,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
     if(i)
        LEAVE;
 #endif
-    if(to_dec)
-       SvREFCNT_dec(to_dec);
+    SvREFCNT_dec(to_dec);
     return 0;
 }
 #endif /* !PERL_MICRO */
@@ -2357,8 +2356,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
 #endif
        }
        else if (strEQ(mg->mg_ptr+1, "NCODING")) {
-           if (PL_encoding)
-               SvREFCNT_dec(PL_encoding);
+           SvREFCNT_dec(PL_encoding);
            if (SvOK(sv) || SvGMAGICAL(sv)) {
                PL_encoding = newSVsv(sv);
            }
@@ -2537,8 +2535,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
        PL_rs = newSVsv(sv);
        break;
     case '\\':
-       if (PL_ors_sv)
-           SvREFCNT_dec(PL_ors_sv);
+       SvREFCNT_dec(PL_ors_sv);
        if (SvOK(sv) || SvGMAGICAL(sv)) {
            PL_ors_sv = newSVsv(sv);
        }
index 36bf0ac..7da7505 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -614,10 +614,8 @@ PerlIO_list_free(pTHX_ PerlIO_list_t *list)
        if (--list->refcnt == 0) {
            if (list->array) {
                IV i;
-               for (i = 0; i < list->cur; i++) {
-                   if (list->array[i].arg)
-                       SvREFCNT_dec(list->array[i].arg);
-               }
+               for (i = 0; i < list->cur; i++)
+                   SvREFCNT_dec(list->array[i].arg);
                Safefree(list->array);
            }
            Safefree(list);
@@ -1038,8 +1036,7 @@ PerlIO_parse_layers(pTHX_ PerlIO_list_t *av, const char *names)
                            arg = newSVpvn(as, alen);
                        PerlIO_list_push(aTHX_ av, layer,
                                         (arg) ? arg : &PL_sv_undef);
-                       if (arg)
-                           SvREFCNT_dec(arg);
+                       SvREFCNT_dec(arg);
                    }
                    else {
                        Perl_ck_warner(aTHX_ packWARN(WARN_LAYER), "Unknown PerlIO layer \"%.*s\"",
@@ -1563,8 +1560,7 @@ PerlIO_openn(pTHX_ const char *layers, const char *mode, int fd,
                    arg = (*l->tab->Getarg) (aTHX_ &l, NULL, 0);
                PerlIO_list_push(aTHX_ layera, l->tab,
                                 (arg) ? arg : &PL_sv_undef);
-               if (arg)
-                   SvREFCNT_dec(arg);
+               SvREFCNT_dec(arg);
                l = *PerlIONext(&l);
            }
        }
@@ -2269,8 +2265,7 @@ PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
        f = PerlIO_push(aTHX_ f, self, PerlIO_modestr(o,buf), arg);
        if (PerlIOBase(o)->flags & PERLIO_F_UTF8)
            PerlIOBase(f)->flags |= PERLIO_F_UTF8;
-       if (arg)
-           SvREFCNT_dec(arg);
+       SvREFCNT_dec(arg);
     }
     return f;
 }
@@ -5181,8 +5176,7 @@ PerlIO_tmpfile(void)
               PerlIOBase(f)->flags |= PERLIO_F_TEMP;
          PerlLIO_unlink(sv ? SvPVX_const(sv) : tempname);
      }
-     if (sv)
-        SvREFCNT_dec(sv);
+     SvREFCNT_dec(sv);
 #    else      /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */
      FILE * const stdio = PerlSIO_tmpfile();
 
diff --git a/pp.c b/pp.c
index bb0e57d..86d79fb 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -3200,8 +3200,7 @@ PP(pp_substr)
            sv_insert_flags(sv, pos, rem, repl, repl_len, 0);
            if (repl_is_utf8)
                SvUTF8_on(sv);
-           if (repl_sv_copy)
-               SvREFCNT_dec(repl_sv_copy);
+           SvREFCNT_dec(repl_sv_copy);
        }
        else if (lvalue) {              /* it's an lvalue! */
            if (!SvGMAGICAL(sv)) {
@@ -3381,8 +3380,7 @@ PP(pp_index)
        if (retval > 0 && big_utf8)
            sv_pos_b2u(big, &retval);
     }
-    if (temp)
-       SvREFCNT_dec(temp);
+    SvREFCNT_dec(temp);
  fail:
     PUSHi(retval + arybase);
     RETURN;
index ee033bc..80c59bc 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1161,8 +1161,7 @@ Perl_setdefout(pTHX_ GV *gv)
 {
     dVAR;
     SvREFCNT_inc_simple_void(gv);
-    if (PL_defoutgv)
-       SvREFCNT_dec(PL_defoutgv);
+    SvREFCNT_dec(PL_defoutgv);
     PL_defoutgv = gv;
 }
 
index eb5f12f..dd03745 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -6790,8 +6790,7 @@ S_reg_namedseq(pTHX_ RExC_state_t *pRExC_state, UV *valuep, I32 *flagp)
                       SVfARG(sv_name)
                 );
         }
-        if (sv_name)    
-            SvREFCNT_dec(sv_name);    
+        SvREFCNT_dec(sv_name);
         if (!cached)
             SvREFCNT_dec(sv_str);    
         return len ? NULL : (regnode *)&len;
@@ -6869,12 +6868,9 @@ S_reg_namedseq(pTHX_ RExC_state_t *pRExC_state, UV *valuep, I32 *flagp)
     } else {   /* zero length */
         ret = reg_node(pRExC_state,NOTHING);
     }
-    if (!cached) {
+    SvREFCNT_dec(sv_name);
+    if (!cached)
         SvREFCNT_dec(sv_str);
-    }
-    if (sv_name) {
-        SvREFCNT_dec(sv_name); 
-    }
     return ret;
 
 }
@@ -8442,9 +8438,7 @@ parseit:
         *STRING(ret)= (char)value;
         STR_LEN(ret)= 1;
         RExC_emit += STR_SZ(1);
-       if (listsv) {
-           SvREFCNT_dec(listsv);
-       }
+       SvREFCNT_dec(listsv);
         return ret;
     }
     /* optimize case-insensitive simple patterns (e.g. /[a-z]/i) */
@@ -9407,24 +9401,18 @@ Perl_pregfree2(pTHX_ REGEXP *rx)
         ReREFCNT_dec(r->mother_re);
     } else {
         CALLREGFREE_PVT(rx); /* free the private data */
-        if (RXp_PAREN_NAMES(r))
-            SvREFCNT_dec(RXp_PAREN_NAMES(r));
+        SvREFCNT_dec(RXp_PAREN_NAMES(r));
     }        
     if (r->substrs) {
-        if (r->anchored_substr)
-            SvREFCNT_dec(r->anchored_substr);
-        if (r->anchored_utf8)
-            SvREFCNT_dec(r->anchored_utf8);
-        if (r->float_substr)
-            SvREFCNT_dec(r->float_substr);
-        if (r->float_utf8)
-            SvREFCNT_dec(r->float_utf8);
+        SvREFCNT_dec(r->anchored_substr);
+        SvREFCNT_dec(r->anchored_utf8);
+        SvREFCNT_dec(r->float_substr);
+        SvREFCNT_dec(r->float_utf8);
        Safefree(r->substrs);
     }
     RX_MATCH_COPY_FREE(rx);
 #ifdef PERL_OLD_COPY_ON_WRITE
-    if (r->saved_copy)
-        SvREFCNT_dec(r->saved_copy);
+    SvREFCNT_dec(r->saved_copy);
 #endif
     Safefree(r->offs);
 }
index ec09c28..06fe13a 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -961,9 +961,9 @@ Perl_re_intuit_start(pTHX_ REGEXP * const rx, SV *sv, char *strpos,
        {
            /* If flags & SOMETHING - do not do it many times on the same match */
            DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "... Disabling check substring...\n"));
+           /* XXX Does the destruction order has to change with do_utf8? */
            SvREFCNT_dec(do_utf8 ? prog->check_utf8 : prog->check_substr);
-           if (do_utf8 ? prog->check_substr : prog->check_utf8)
-               SvREFCNT_dec(do_utf8 ? prog->check_substr : prog->check_utf8);
+           SvREFCNT_dec(do_utf8 ? prog->check_substr : prog->check_utf8);
            prog->check_substr = prog->check_utf8 = NULL;       /* disable */
            prog->float_substr = prog->float_utf8 = NULL;       /* clear */
            check = NULL;                       /* abort */
diff --git a/scope.c b/scope.c
index 50798e4..1d5701e 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -747,9 +747,7 @@ Perl_leave_scope(pTHX_ I32 base)
        case SAVEt_AV:                          /* array reference */
            av = MUTABLE_AV(SSPOPPTR);
            gv = MUTABLE_GV(SSPOPPTR);
-           if (GvAV(gv)) {
-               SvREFCNT_dec(GvAV(gv));
-           }
+           SvREFCNT_dec(GvAV(gv));
            GvAV(gv) = av;
            if (SvMAGICAL(av)) {
                PL_localizing = 2;
@@ -760,9 +758,7 @@ Perl_leave_scope(pTHX_ I32 base)
        case SAVEt_HV:                          /* hash reference */
            hv = MUTABLE_HV(SSPOPPTR);
            gv = MUTABLE_GV(SSPOPPTR);
-           if (GvHV(gv)) {
-               SvREFCNT_dec(GvHV(gv));
-           }
+           SvREFCNT_dec(GvHV(gv));
            GvHV(gv) = hv;
            if (SvMAGICAL(hv)) {
                PL_localizing = 2;