Except that, with earlier perls, the new buffer is the same length as the old buffer
That's not true. When older Perls create a new buffer, they are just a bit larger than necessary, just like in 5.42.
In all the examples where you claim there's a new buffer was allocated based on the size of the old one, you are mistaken. As I explained, no new buffer was allocated in those cases. set_sv is simply modifying the existing buffer, something you can't do with shared buffer. And since Perl never shrinks a buffer, modifying the buffer does not shrink it.[1]
It can free it, e.g. using undef $s; (as opposed to $s = undef;), which could eventually result with a shorter buffer in $s. But I don't know of any circumstances in which it directly shrinks a buffer.
In reply to Re^3: [XS] sv_setpv change in behaviour with perl-5.42.0 and later
by ikegami
in thread [XS] sv_setpv change in behaviour with perl-5.42.0 and later
by syphilis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |