diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-10-11 00:24:18 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-10-11 23:07:34 -0700 |
commit | 64534138a19b24be2454457bdf70ffb0d983b248 (patch) | |
tree | f290aa95bf6601f5e2b18f5e28d6cc3706e82a56 /sv.h | |
parent | a0dd190b98da5a187fe751068264c32007af3931 (diff) | |
download | perl-64534138a19b24be2454457bdf70ffb0d983b248.tar.gz |
Simplify the fix for bug #41530
We don’t need to upgrade the target string and redo the pattern match
if the replacement is in utf8. We can simply convert during concate-
nation, using the more recently added SV_CATUTF8 and SV_CATBYTES flags
to sv_catpvn_flags.
This should make things faster, too, as sv_catpvn_flags does not need
to allocate extra SVs or string buffers.
This happened to trigger an existing COW bug, causing test failures.
SvIsCOW and sv_force_normal_flags were being called on TARG before
get-magic. So a magical scalar returning a COW could have that COW
modified in place.
I added a test for something I nearly broke.
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1819,6 +1819,8 @@ mg.c:1024: warning: left-hand operand of comma expression has no effect sv_utf8_upgrade(nsv); \ sv_catsv_nomg(dsv, nsv); \ } STMT_END +#define sv_catpvn_nomg_maybeutf8(dsv, sstr, slen, is_utf8) \ + sv_catpvn_flags(dsv, sstr, slen, (is_utf8)?SV_CATUTF8:SV_CATBYTES) #ifdef PERL_CORE # define sv_or_pv_len_utf8(sv, pv, bytelen) \ |