summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-10-19 14:14:05 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-20 12:38:06 -0700
commit810a07df93924c82fc5bbe83c8f12a0def2fb61d (patch)
treebdc1bc1b5a7834718250e9b4fcb247388d1c04a9 /doop.c
parentb3153e044595a17d3f7e3c62468beb8c8f8ac96d (diff)
downloadperl-810a07df93924c82fc5bbe83c8f12a0def2fb61d.tar.gz
Call string overloading once in join($ov,...)
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/doop.c b/doop.c
index 007ff5e2e3..62edb06297 100644
--- a/doop.c
+++ b/doop.c
@@ -669,12 +669,10 @@ Perl_do_join(pTHX_ SV *sv, SV *delim, SV **mark, SV **sp)
I32 items = sp - mark;
STRLEN len;
STRLEN delimlen;
+ const char * const delims = SvPV_const(delim, delimlen);
PERL_ARGS_ASSERT_DO_JOIN;
- (void) SvPV_const(delim, delimlen); /* stringify and get the delimlen */
- /* SvCUR assumes it's SvPOK() and woe betide you if it's not. */
-
mark++;
len = (items > 0 ? (delimlen * (items - 1) ) : 0);
SvUPGRADE(sv, SVt_PV);
@@ -708,10 +706,11 @@ Perl_do_join(pTHX_ SV *sv, SV *delim, SV **mark, SV **sp)
}
if (delimlen) {
+ const U32 delimflag = DO_UTF8(delim) ? SV_CATUTF8 : SV_CATBYTES;
for (; items > 0; items--,mark++) {
STRLEN len;
const char *s;
- sv_catsv_nomg(sv,delim);
+ sv_catpvn_flags(sv,delims,delimlen,delimflag);
s = SvPV_const(*mark,len);
sv_catpvn_flags(sv,s,len,
DO_UTF8(*mark) ? SV_CATUTF8 : SV_CATBYTES);