tidy up patten match copying code
authorDavid Mitchell <davem@iabyn.com>
Sat, 1 Sep 2012 10:23:58 +0000 (11:23 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 8 Sep 2012 14:42:07 +0000 (15:42 +0100)
(no functional changes).

1. Remove some dead code from pp_split; it's protected by an assert
that it could never be called.

2. Simplify the flags settings for the call to CALLREGEXEC() in
pp_substcont: on subsequent matches we always set REXEC_NOT_FIRST,
which forces the regex engine not to copy anyway, so passing the
REXEC_COPY_STR is pointless, as is the conditional code to set it.

3. (whitespace change): split a conditional expression over 2 lines
for easier reading.

pp.c
pp_ctl.c
pp_hot.c

diff --git a/pp.c b/pp.c
index 1c7b18a..e1a6c78 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -5552,13 +5552,6 @@ PP(pp_split)
             /* we never pass the REXEC_COPY_STR flag, so it should
              * never get copied */
             assert(!RX_MATCH_COPIED(rx));
-           if (RX_MATCH_COPIED(rx) && RX_SUBBEG(rx) != orig) {
-               m = s;
-               s = orig;
-               orig = RX_SUBBEG(rx);
-               s = orig + (m - s);
-               strend = s + (strend - m);
-           }
            m = RX_OFFS(rx)[0].start + orig;
 
            if (gimme_scalar) {
index ecb8c9f..af0d558 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -216,9 +216,7 @@ PP(pp_substcont)
        if (CxONCE(cx) || s < orig ||
                !CALLREGEXEC(rx, s, cx->sb_strend, orig,
                             (s == m) + RX_GOFS(rx), cx->sb_targ, NULL,
-                            ((cx->sb_rflags & REXEC_COPY_STR)
-                             ? (REXEC_IGNOREPOS|REXEC_NOT_FIRST)
-                             : (REXEC_COPY_STR|REXEC_IGNOREPOS|REXEC_NOT_FIRST))))
+                                (REXEC_IGNOREPOS|REXEC_NOT_FIRST)))
        {
            SV *targ = cx->sb_targ;
 
index 6530ae5..b549d1c 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2217,7 +2217,8 @@ PP(pp_subst)
 #ifdef PERL_OLD_COPY_ON_WRITE
        && !is_cow
 #endif
-       && (I32)clen <= RX_MINLENRET(rx) && (once || !(r_flags & REXEC_COPY_STR))
+        && (I32)clen <= RX_MINLENRET(rx)
+        && (once || !(r_flags & REXEC_COPY_STR))
        && !(RX_EXTFLAGS(rx) & RXf_LOOKBEHIND_SEEN)
        && (!doutf8 || SvUTF8(TARG))
        && !(rpm->op_pmflags & PMf_NONDESTRUCT))