This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
in Perl_sv_copypv_flags move mg_get call to callee
authorDaniel Dragan <bulk88@hotmail.com>
Thu, 18 Sep 2014 16:44:15 +0000 (12:44 -0400)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 18 Sep 2014 19:54:43 +0000 (12:54 -0700)
Perl_sv_2pv_flags already has logic to check for and call mg_get, which
can't be removed due to API, so dont do it in the caller. This makes
Perl_sv_copypv_flags smaller/faster by removing the branch.

sv.c

diff --git a/sv.c b/sv.c
index 8e52a99..9723d3c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3157,9 +3157,7 @@ Perl_sv_copypv_flags(pTHX_ SV *const dsv, SV *const ssv, const I32 flags)
 
     PERL_ARGS_ASSERT_SV_COPYPV_FLAGS;
 
-    if ((flags & SV_GMAGIC) && SvGMAGICAL(ssv))
-       mg_get(ssv);
-    s = SvPV_nomg_const(ssv,len);
+    s = SvPV_flags_const(ssv,len,flags & SV_GMAGIC);
     sv_setpvn(dsv,s,len);
     if (SvUTF8(ssv))
        SvUTF8_on(dsv);