This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sv.c: %vd printf format microöptimisation
authorFather Chrysostomos <sprout@cpan.org>
Thu, 13 Sep 2012 21:08:46 +0000 (14:08 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 15 Sep 2012 05:29:42 +0000 (22:29 -0700)
The %vd printf format does not need to make two copies of a version
object’s stringification or stringify the object twice.

sv.c

diff --git a/sv.c b/sv.c
index 61c67b0..5996ec1 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10375,18 +10375,15 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                 * vectorize happen normally
                 */
                if (sv_isobject(vecsv) && sv_derived_from(vecsv, "version")) {
-                   char *version;
                    if ( hv_exists(MUTABLE_HV(SvRV(vecsv)), "alpha", 5 ) ) {
                        Perl_ck_warner_d(aTHX_ packWARN(WARN_PRINTF),
                        "vector argument not supported with alpha versions");
                        goto vdblank;
                    }
-                   version = savesvpv(vecsv);
                    vecsv = sv_newmortal();
-                   scan_vstring(version, version + veclen, vecsv);
+                   scan_vstring(vecstr, vecstr + veclen, vecsv);
                    vecstr = (U8*)SvPV_const(vecsv, veclen);
                    vec_utf8 = DO_UTF8(vecsv);
-                   Safefree(version);
                }
            }
            else {