This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don’t sv_force_normal in mg.c:S_save_magic
authorFather Chrysostomos <sprout@cpan.org>
Sat, 27 Oct 2012 01:20:16 +0000 (18:20 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 09:04:56 +0000 (02:04 -0700)
commit2fd13eccf08a49ced523195b1297d74a03211ebb
tree5052963173b12b8a1d5cf0319a99c52d91113dd6
parent560a4009bab00b294a28f584f9b812b7c1273d94
Don’t sv_force_normal in mg.c:S_save_magic

This was added to make SvREADONLY_off safe.  (I think read-only is
turned off during magic so the magic scalar itself can be set without
the sv_set* functions getting upset.)  Since SvREADONLY doesn’t mean
read-only for COWs, we don’t actually need to do sv_force_normal, but
can simply skip SvREADONLY_off for COWs.

By leaving it to sv_set* functions to do sv_force_normal, we avoid
having to copy the string buffer if it is just going to be thrown away
anyway.  S_save_magic can’t know whether the scalar will actually be
overwritten, so it has to copy the buffer.
mg.c