From f0ee386351fbbf1a41ead86e9163f688d1b37dc1 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Fri, 17 Oct 2014 18:14:40 -0700 Subject: [PATCH] Use sv_catpvn instead of sv_catsv in doop.c:do_join MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bunchmarking shows that SvPV+sv_catpvn is faster that sv_catsv. Why exactly I don’t know, but perhaps fewer functions and flag checks are the cause. --- doop.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doop.c b/doop.c index 3b6f1e7..007ff5e 100644 --- a/doop.c +++ b/doop.c @@ -709,13 +709,22 @@ Perl_do_join(pTHX_ SV *sv, SV *delim, SV **mark, SV **sp) if (delimlen) { for (; items > 0; items--,mark++) { + STRLEN len; + const char *s; sv_catsv_nomg(sv,delim); - sv_catsv(sv,*mark); + s = SvPV_const(*mark,len); + sv_catpvn_flags(sv,s,len, + DO_UTF8(*mark) ? SV_CATUTF8 : SV_CATBYTES); } } else { for (; items > 0; items--,mark++) - sv_catsv(sv,*mark); + { + STRLEN len; + const char *s = SvPV_const(*mark,len); + sv_catpvn_flags(sv,s,len, + DO_UTF8(*mark) ? SV_CATUTF8 : SV_CATBYTES); + } } SvSETMAGIC(sv); } -- 1.8.3.1