This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make S_already_defined() in op.c return void
authorDavid Mitchell <davem@iabyn.com>
Mon, 5 Sep 2016 11:46:02 +0000 (12:46 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 5 Sep 2016 11:56:45 +0000 (12:56 +0100)
Currently it returns a boolean value, but after the removal of the MAD
code, this value is just equivalent to its 'block' arg; so instead just
make its callers test 'block' instead. This makes the calling code in
newATTRSUB_x and newMYSUB easier to follow.

Also, put the block condition on a single line (whitespace change)

op.c

diff --git a/op.c b/op.c
index 42eefa7..7d33b72 100644 (file)
--- a/op.c
+++ b/op.c
@@ -7991,15 +7991,14 @@ S_op_const_sv(pTHX_ const OP *o, CV *cv, bool allow_lex)
     return sv;
 }
 
-static bool
+static void
 S_already_defined(pTHX_ CV *const cv, OP * const block, OP * const o,
                        PADNAME * const name, SV ** const const_svp)
 {
     assert (cv);
     assert (o || name);
     assert (const_svp);
-    if ((!block
-        )) {
+    if (!block) {
        if (CvFLAGS(PL_compcv)) {
            /* might have had built-in attrs applied */
            const bool pureperl = !CvISXSUB(cv) && CvROOT(cv);
@@ -8015,7 +8014,7 @@ S_already_defined(pTHX_ CV *const cv, OP * const block, OP * const o,
                (CvFLAGS(PL_compcv) & CVf_BUILTIN_ATTRS
                  & ~(CVf_LVALUE * pureperl));
        }
-       return FALSE;
+       return;
     }
 
     /* redundant check for speed: */
@@ -8037,7 +8036,7 @@ S_already_defined(pTHX_ CV *const cv, OP * const block, OP * const o,
        CopLINE_set(PL_curcop, oldline);
     }
     SAVEFREESV(cv);
-    return TRUE;
+    return;
 }
 
 CV *
@@ -8169,7 +8168,8 @@ Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
                                  ps_utf8);
        /* already defined? */
        if (exists) {
-           if (S_already_defined(aTHX_ cv,block,NULL,name,&const_sv))
+           S_already_defined(aTHX_ cv, block, NULL, name, &const_sv);
+            if (block)
                cv = NULL;
            else {
                if (attrs)
@@ -8631,7 +8631,8 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
             cv_ckproto_len_flags(cv, gv, ps, ps_len, ps_utf8);
        /* already defined (or promised)? */
        if (exists || (isGV(gv) && GvASSUMECV(gv))) {
-           if (S_already_defined(aTHX_ cv, block, o, NULL, &const_sv))
+           S_already_defined(aTHX_ cv, block, o, NULL, &const_sv);
+            if (block)
                cv = NULL;
            else {
                if (attrs)