This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Squash COWs in the char* typemap
authorFather Chrysostomos <sprout@cpan.org>
Sun, 24 Nov 2013 00:38:30 +0000 (16:38 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 24 Nov 2013 00:41:20 +0000 (16:41 -0800)
commit77ca9de6373481d905eed6af2904599353a658b3
tree7dc1a52b1f7fb20da60e580ed2a08e72ec2a33cc
parenta2235d78944d9a704217e0fc4943f3f90ac51cc8
Squash COWs in the char* typemap

Some XS modules expect to be able to modify strings passed in as char
pointers.  Copy-on-write breaks that ability.  So this commit makes
the T_PV typemap uncow mutable COWs when passing them.

const char* is now mapped to the new T_ROPV entry, to avoiding unnec-
essarily slowing it down.

Steffen Müller writes in <52912E9C.3030403@cpan.org> that the typemap
is not dual-lifed, so it is not necessary to make this 5.16-compati-
ble.  However, I had already written the patch, and I think it is good
to keep it possible to drop this typemap into a CPAN distribution.
Any self-respecting C compiler should be able to optimise away the
extra SvIsCOW(t_pv_tmp_sv) == 1 check, so there is no slowdown as a
result of compatibility.
ext/XS-Typemap/Typemap.pm
ext/XS-Typemap/Typemap.xs
ext/XS-Typemap/t/Typemap.t
lib/ExtUtils/typemap