SvREFCNT_dec already checks if the SV is non-NULL
authorVincent Pit <vince@profvince.com>
Tue, 2 Aug 2011 10:17:47 +0000 (12:17 +0200)
committerVincent Pit <vince@profvince.com>
Tue, 2 Aug 2011 10:17:47 +0000 (12:17 +0200)
gv.c
hv.c
scope.c

diff --git a/gv.c b/gv.c
index 79bc0e9..12ff1f3 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -411,7 +411,6 @@ Perl_gv_fetchmeth(pTHX_ HV *stash, const char *name, STRLEN len, I32 level)
     HV* cstash;
     GV* candidate = NULL;
     CV* cand_cv = NULL;
-    CV* old_cv;
     GV* topgv = NULL;
     const char *hvname;
     I32 create = (level >= 0) ? 1 : 0;
@@ -505,7 +504,8 @@ Perl_gv_fetchmeth(pTHX_ HV *stash, const char *name, STRLEN len, I32 level)
              *  2. method isn't a stub (else AUTOLOAD fails spectacularly)
              */
             if (topgv && (GvREFCNT(topgv) == 1) && (CvROOT(cand_cv) || CvXSUB(cand_cv))) {
-                  if ((old_cv = GvCV(topgv))) SvREFCNT_dec(old_cv);
+                  CV *old_cv = GvCV(topgv);
+                  SvREFCNT_dec(old_cv);
                   SvREFCNT_inc_simple_void_NN(cand_cv);
                   GvCV_set(topgv, cand_cv);
                   GvCVGEN(topgv) = topgen_cmp;
@@ -520,7 +520,8 @@ Perl_gv_fetchmeth(pTHX_ HV *stash, const char *name, STRLEN len, I32 level)
         if(candidate) {
             cand_cv = GvCV(candidate);
             if (topgv && (GvREFCNT(topgv) == 1) && (CvROOT(cand_cv) || CvXSUB(cand_cv))) {
-                  if ((old_cv = GvCV(topgv))) SvREFCNT_dec(old_cv);
+                  CV *old_cv = GvCV(topgv);
+                  SvREFCNT_dec(old_cv);
                   SvREFCNT_inc_simple_void_NN(cand_cv);
                   GvCV_set(topgv, cand_cv);
                   GvCVGEN(topgv) = topgen_cmp;
diff --git a/hv.c b/hv.c
index f8f16b6..d6ecfb4 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1813,7 +1813,7 @@ Perl_hv_undef_flags(pTHX_ HV *hv, U32 flags)
            SvREFCNT_dec(meta->mro_linear_current);
            meta->mro_linear_current = NULL;
        }
-       if(meta->mro_nextmethod) SvREFCNT_dec(meta->mro_nextmethod);
+       SvREFCNT_dec(meta->mro_nextmethod);
        SvREFCNT_dec(meta->isa);
        Safefree(meta);
        aux->xhv_mro_meta = NULL;
diff --git a/scope.c b/scope.c
index e0ba9a3..9a43eb0 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -740,8 +740,7 @@ Perl_leave_scope(pTHX_ I32 base)
            SvSETMAGIC(value);
            PL_localizing = 0;
            SvREFCNT_dec(value);
-           if (av) /* actually an av, hv or gv */
-               SvREFCNT_dec(av);
+           SvREFCNT_dec(av); /* av may actually be an AV, HV or GV */
            break;
        case SAVEt_GENERIC_PVREF:               /* generic pv */
            ptr = SSPOPPTR;