Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 08223ba8c819f556b4b6787bcdead768f200b00b
      
https://github.com/Perl/perl5/commit/08223ba8c819f556b4b6787bcdead768f200b00b
  Author: Richard Leach <richardle...@users.noreply.github.com>
  Date:   2024-11-12 (Tue, 12 Nov 2024)

  Changed paths:
    M pp.c

  Log Message:
  -----------
  pp_reverse: don't COW buffer just to then un-COW it

When it has a single argument, scalar-mode `pp_reverse` copies the
source PV buffer to the destination PV buffer via the `sv_setsv()`
macro. This expands to:

        sv_setsv_flags(dsv, ssv, SV_GMAGIC|SV_DO_COW_SVSETSV)

The `SV_DO_COW_SVSETSV` flag means that Perl_sv_setsv_flags will
try to achieve the "copy" via these mechanisms:
* Swipe the source buffer (if possible)
* COW the buffer (if possible)
* Copy the buffer

However, using COW makes no sense because pp_reverse is going to
then modify the buffer. Almost immediately after the `sv_setsv`
call, any COWing will be reversed by the call to `SvPV_force` and
a full copy of the buffer taken. So this commit expands the
`sv_setsv` call and drops the COW flag.



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to