In Perl_cv_forget_slab(), simplify the conditionally compiled code.
authorNicholas Clark <nick@ccl4.org>
Tue, 4 Sep 2012 09:54:06 +0000 (11:54 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 4 Sep 2012 09:54:06 +0000 (11:54 +0200)
This refactoring reduces the line count and makes it clear that the basic
logic is the same with or without -DPERL_DEBUG_READONLY_OPS. It make no
change to the generated assembler on a normal build.

pad.c

diff --git a/pad.c b/pad.c
index 148fdf8..aba463b 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -505,9 +505,7 @@ void
 Perl_cv_forget_slab(pTHX_ CV *cv)
 {
     const bool slabbed = !!CvSLABBED(cv);
-#ifdef PERL_DEBUG_READONLY_OPS
     OPSLAB *slab = NULL;
-#endif
 
     PERL_ARGS_ASSERT_CV_FORGET_SLAB;
 
@@ -515,25 +513,21 @@ Perl_cv_forget_slab(pTHX_ CV *cv)
 
     CvSLABBED_off(cv);
 
-#ifdef PERL_DEBUG_READONLY_OPS
     if      (CvROOT(cv))  slab = OpSLAB(CvROOT(cv));
     else if (CvSTART(cv)) slab = (OPSLAB *)CvSTART(cv);
-#else
-    if      (CvROOT(cv))  OpslabREFCNT_dec(OpSLAB(CvROOT(cv)));
-    else if (CvSTART(cv)) OpslabREFCNT_dec((OPSLAB *)CvSTART(cv));
-#endif
 #ifdef DEBUGGING
     else if (slabbed)     Perl_warn(aTHX_ "Slab leaked from cv %p", cv);
 #endif
 
-#ifdef PERL_DEBUG_READONLY_OPS
     if (slab) {
-       size_t refcnt;
-       refcnt = slab->opslab_refcnt;
+#ifdef PERL_DEBUG_READONLY_OPS
+       const size_t refcnt = slab->opslab_refcnt;
+#endif
        OpslabREFCNT_dec(slab);
+#ifdef PERL_DEBUG_READONLY_OPS
        if (refcnt > 1) Slab_to_ro(slab);
-    }
 #endif
+    }
 }
 
 /*