Use the new SV_NOSTEAL flag to avoid the SvTEMP dance in newSVsv
authorNicholas Clark <nick@ccl4.org>
Thu, 13 Jan 2005 23:13:05 +0000 (23:13 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 13 Jan 2005 23:13:05 +0000 (23:13 +0000)
p4raw-id: //depot/perl@23797

sv.c

diff --git a/sv.c b/sv.c
index b1edb2f..e9e0eca 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -7858,13 +7858,10 @@ Perl_newSVsv(pTHX_ register SV *old)
        return Nullsv;
     }
     new_SV(sv);
-    if (SvTEMP(old)) {
-       SvTEMP_off(old);
-       sv_setsv(sv,old);
-       SvTEMP_on(old);
-    }
-    else
-       sv_setsv(sv,old);
+    /* SV_GMAGIC is the default for sv_setv()
+       SV_NOSTEAL prevents TEMP buffers being, well, stolen, and saves games
+       with SvTEMP_off and SvTEMP_on round a call to sv_setsv.  */
+    sv_setsv_flags(sv, old, SV_GMAGIC | SV_NOSTEAL);
     return sv;
 }