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
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.