This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #121259] Always allow COW after $input=<>
sv_grow provides an extra byte for the sake of copy-on-write’s buffer
reference count, but skips this for multiples of 256 (though the com-
ments there say powers of two).
When we do
$input=<>
The assignment is optimised away and the allocation takes place in
sv_gets. In that code path, we know we don’t need a nice power of
two and allocating an extra byte won’t hurt, so go ahead and add an
extra byte.
This speeds up code doing m//g on $input, because it avoids the pre-
match copy.