This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.c: add code comments to S_search_const()
authorDavid Mitchell <davem@iabyn.com>
Tue, 28 May 2019 16:25:33 +0000 (17:25 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 24 Jun 2019 10:40:07 +0000 (11:40 +0100)
plus a few blank lines for readability.

op.c

diff --git a/op.c b/op.c
index 063a8fb..ab185fd 100644 (file)
--- a/op.c
+++ b/op.c
@@ -8354,6 +8354,12 @@ Perl_newLOGOP(pTHX_ I32 type, I32 flags, OP *first, OP *other)
     return new_logop(type, flags, &first, &other);
 }
 
     return new_logop(type, flags, &first, &other);
 }
 
+
+/* See if the optree o contains a single OP_CONST (plus possibly
+ * surrounding enter/nextstate/null etc). If so, return it, else return
+ * NULL.
+ */
+
 STATIC OP *
 S_search_const(pTHX_ OP *o)
 {
 STATIC OP *
 S_search_const(pTHX_ OP *o)
 {
@@ -8374,6 +8380,7 @@ S_search_const(pTHX_ OP *o)
            if (!(o->op_flags & OPf_KIDS))
                return NULL;
            kid = cLISTOPo->op_first;
            if (!(o->op_flags & OPf_KIDS))
                return NULL;
            kid = cLISTOPo->op_first;
+
            do {
                switch (kid->op_type) {
                    case OP_ENTER:
            do {
                switch (kid->op_type) {
                    case OP_ENTER:
@@ -8387,6 +8394,7 @@ S_search_const(pTHX_ OP *o)
                        goto last;
                }
            } while (kid);
                        goto last;
                }
            } while (kid);
+
            if (!kid)
                kid = cLISTOPo->op_last;
           last:
            if (!kid)
                kid = cLISTOPo->op_last;
           last:
@@ -8397,6 +8405,7 @@ S_search_const(pTHX_ OP *o)
     return NULL;
 }
 
     return NULL;
 }
 
+
 STATIC OP *
 S_new_logop(pTHX_ I32 type, I32 flags, OP** firstp, OP** otherp)
 {
 STATIC OP *
 S_new_logop(pTHX_ I32 type, I32 flags, OP** firstp, OP** otherp)
 {