Move all code that relies on reading the to-be-thrown-away buffer ahead
Nicholas Clark [Sat, 29 Dec 2007 19:32:52 +0000 (19:32 +0000)]
of the call to sv_chop() that throws it away.

p4raw-id: //depot/perl@32777

pp_hot.c
sv.c

index f987357..c6b5c5c 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2197,10 +2197,8 @@ PP(pp_subst)
            else if ((i = m - s)) {     /* faster from front */
                d -= clen;
                m = d;
+               Move(s, d - i, i, char);
                sv_chop(TARG, d-i);
-               s += i;
-               while (i--)
-                   *--d = *--s;
                if (clen)
                    Copy(c, m, clen, char);
            }
diff --git a/sv.c b/sv.c
index 913a5da..bb64eb9 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4994,10 +4994,8 @@ Perl_sv_insert(pTHX_ SV *bigstr, STRLEN offset, STRLEN len, const char *little,
     else if ((i = mid - big)) {        /* faster from front */
        midend -= littlelen;
        mid = midend;
+       Move(big, midend - i, i, char);
        sv_chop(bigstr,midend-i);
-       big += i;
-       while (i--)
-           *--midend = *--big;
        if (littlelen)
            Move(little, mid, littlelen,char);
     }