This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge 2 gv_fetch* calls in Perl_newXS_len_flags
authorDaniel Dragan <bulk88@hotmail.com>
Sun, 7 Oct 2012 16:06:24 +0000 (12:06 -0400)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 7 Oct 2012 19:15:50 +0000 (12:15 -0700)
Merge a gv_fetchpvn and a gv_fetchpv. A strlen call is avoided in
gv_fetchpv, and in Perl_newXS_len_flags shorter machine code because 2
different call destinations were merged to 1, and
"GV_ADDMULTI | flags,SVt_PVCV"  arguments are unconditionally executed
and are not in a branch.

op.c

diff --git a/op.c b/op.c
index fa48148..d3df75e 100644 (file)
--- a/op.c
+++ b/op.c
@@ -7851,13 +7851,11 @@ Perl_newXS_len_flags(pTHX_ const char *name, STRLEN len,
     PERL_ARGS_ASSERT_NEWXS_LEN_FLAGS;
 
     {
-        GV * const gv = name
-                        ? gv_fetchpvn(
-                               name,len,GV_ADDMULTI|flags,SVt_PVCV
-                          )
-                        : gv_fetchpv(
-                            (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"),
-                            GV_ADDMULTI | flags, SVt_PVCV);
+        GV * const gv = gv_fetchpvn(
+                           name ? name : PL_curstash ? "__ANON__" : "__ANON__::__ANON__",
+                           name ? len : PL_curstash ? sizeof("__ANON__") - 1:
+                               sizeof("__ANON__::__ANON__") - 1,
+                           GV_ADDMULTI | flags, SVt_PVCV);
     
         if (!subaddr)
             Perl_croak(aTHX_ "panic: no address for '%s' in '%s'", name, filename);