pp_concat: Only call SvPV_force_nolen when needed
authorSteffen Mueller <smueller@cpan.org>
Mon, 10 Feb 2014 10:40:31 +0000 (11:40 +0100)
committerSteffen Mueller <smueller@cpan.org>
Mon, 10 Feb 2014 10:40:31 +0000 (11:40 +0100)
If we just did an sv_setpvs on it, the SvPV_force_nolen should not do
anything useful, so let's not.

Side note: s/TARG/left/ in the enclosing block because they are the same
pointer, so why use a define that needs grokking by the reader of the
code if the local variable is guaranteed to be the same?

pp_hot.c

index beb9649..79b77ab 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -278,16 +278,18 @@ PP(pp_concat)
        else
            SvUTF8_off(TARG);
     }
-    else { /* $l .= $r */
-       if (!SvOK(TARG)) {
+    else { /* $l .= $r   and   left == TARG */
+       if (!SvOK(left)) {
            if (left == right && ckWARN(WARN_UNINITIALIZED)) /* $l .= $l */
                report_uninit(right);
            sv_setpvs(left, "");
        }
-       SvPV_force_nomg_nolen(left);
+        else {
+            SvPV_force_nomg_nolen(left);
+        }
        lbyte = !DO_UTF8(left);
        if (IN_BYTES)
-           SvUTF8_off(TARG);
+           SvUTF8_off(left);
     }
 
     if (!rcopied) {