This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In B.xs, use *pvf() functions to reduce the number of API calls.
authorNicholas Clark <nick@ccl4.org>
Tue, 31 Jan 2012 11:02:43 +0000 (12:02 +0100)
committerNicholas Clark <nick@ccl4.org>
Tue, 31 Jan 2012 11:02:43 +0000 (12:02 +0100)
This gives a small reduction in both source lines and object code size.

ext/B/B.xs

index 8a7cbff..4a5ab44 100644 (file)
@@ -784,10 +784,8 @@ ppname(opnum)
        int     opnum
     CODE:
        ST(0) = sv_newmortal();
-       if (opnum >= 0 && opnum < PL_maxo) {
-           sv_setpvs(ST(0), "pp_");
-           sv_catpv(ST(0), PL_op_name[opnum]);
-       }
+       if (opnum >= 0 && opnum < PL_maxo)
+           Perl_sv_setpvf(aTHX_ ST(0), "pp_%s", PL_op_name[opnum]);
 
 void
 hash(sv)
@@ -983,12 +981,12 @@ ppaddr(o)
        B::OP           o
     PREINIT:
        int i;
-       SV *sv = newSVpvs_flags("PL_ppaddr[OP_", SVs_TEMP);
+       SV *sv;
     CODE:
-       sv_catpv(sv, PL_op_name[o->op_type]);
+       sv = sv_2mortal(Perl_newSVpvf(aTHX_ "PL_ppaddr[OP_%s]",
+                                     PL_op_name[o->op_type]));
        for (i=13; (STRLEN)i < SvCUR(sv); ++i)
            SvPVX(sv)[i] = toUPPER(SvPVX(sv)[i]);
-       sv_catpvs(sv, "]");
        ST(0) = sv;
 
 #if PERL_VERSION >= 9