Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 658a5bedcfb012a503b61de6c8cb69924cc6f6f8 https://github.com/Perl/perl5/commit/658a5bedcfb012a503b61de6c8cb69924cc6f6f8 Author: Richard Leach <richardle...@users.noreply.github.com> Date: 2022-09-14 (Wed, 14 Sep 2022)
Changed paths: M sv.c Log Message: ----------- Perl_sv_setsv_flags: return after invlist_clone case In the "first_ switch" statement in Perl_sv_setsv_flags, there's this case: case SVt_INVLIST: invlist_clone(ssv, dsv); break; When the INVLIST code was added, it was unclear whether the logic following that switch needed to apply to INVLISTs or not. Early returns were also seen as risky from a future maintenance perspective. As a precaution, this case was written to `break` rather than `return`. With later analysis though, it seems like the code below this switch does not apply to INVLISTs, apart from one unintended interaction. * invlist_clone() - in regcomp.c - copies the PV buffer of ssv to dsv. * However, whenever an invlist is initialized, SvPOK_on is called on its SV; according to the nearby comment "/* This allows B to extract the PV */". * Because the switch case does not return, the later `if (sflags & SVp_POK)` branch will try to swipe/cow/copy the PV buffer of ssv to dsv. This is an unnecessary double copy. On that analysis, this commit changes the break into a return.