This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Mark COWable constants as COWable at compile time
authorFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 07:02:34 +0000 (00:02 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 12 Aug 2013 08:53:26 +0000 (01:53 -0700)
commit7fa949d0cc67253f8eb6849414789201b5ba722c
tree3d311fc8d1d529afbe7ad08ff05c5575e8e71903
parent4ea34344d710c5231aae2bde41acf5fda78eb175
Mark COWable constants as COWable at compile time

This allows ‘$_ = "hello"’ to do COW without having to copy
that constant.

The reason this did not work before is that we never do copy-on-write
with existing read-only scalars that are not already marked COW, as
doing so modifies the string buffer, which the read-only flag may be
intended to protect.

At compile time, most constants start out mutable and are made read-
only in ck_svconst.  So there we can check that the constant is indeed
still mutable (and COWable) and mark it as a COW scalar before making
it read-only.
ext/Devel-Peek/t/Peek.t
op.c