Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: d002fa41bf2faf250192ebc6fa26bce91c322359 https://github.com/Perl/perl5/commit/d002fa41bf2faf250192ebc6fa26bce91c322359 Author: Richard Leach <richardle...@users.noreply.github.com> Date: 2025-03-12 (Wed, 12 Mar 2025)
Changed paths: M embed.fnc M embed.h M proto.h M sv.c Log Message: ----------- Perl_sv_can_can_swipe_pv_buf - extracts swipe test from Perl_sv_setsv_flags Perl_sv_setsv_flags contains the canonical logic for determining the best method for assigning the string value from a source SV to a destination SV: * "Swipe" the string buffer from the source SV * COW the source SV's string buffer * Do a full copy This commit extracts the "can the swipe the buffer" tests out into a new macro (`S_SvPV_can_swipe_buf`) within sv.c. It has two users: * Perl_sv_setsv_flags - so that the logic remains inline in this hot code * Perl_sv_can_can_swipe_pv_buf - a new function `pp_reverse` will shortly make use of the new function to avoid unnecessary string copies when doing a reversal in scalar context. Commit: 84fa6b0d2566bd50a283a95cb482ef9317647d25 https://github.com/Perl/perl5/commit/84fa6b0d2566bd50a283a95cb482ef9317647d25 Author: Richard Leach <richardle...@users.noreply.github.com> Date: 2025-03-12 (Wed, 12 Mar 2025) Changed paths: M t/op/reverse.t Log Message: ----------- t/op/reverse.t: add a test for single character reversal This could help detect implementation bugs in algorithms for reverse copying from a source buffer to a different destination buffer. Commit: d0b93b3f420aff04038a79c537e62d91eb9f1cdf https://github.com/Perl/perl5/commit/d0b93b3f420aff04038a79c537e62d91eb9f1cdf Author: Richard Leach <richardle...@users.noreply.github.com> Date: 2025-03-12 (Wed, 12 Mar 2025) Changed paths: M pp.c Log Message: ----------- Faster string reversal when source/dest buffers are distinct `pp_reverse()` has traditionally operated on a single string buffer, reversing it in place. When `pp_reverse()` takes a single SV argument, whose buffer cannot be swiped by `sv_setsv_flags()`, a straight copy of the buffer is taken and then that is reversed. In such cases, two complete passes over the entire string are needed to reverse a non-UTF8 string, and reversing a UTF8 string takes three complete passes. This commit enables `pp_reverse()` to apply the "swipe" test itself and, for straightforward copy cases, to avoid calling `sv_setsv_flags()`. Instead, it does the work of preparing the `TARG` SV and reverse copies the string (UTF8 or otherwise) in a single pass. The performance improvement will vary by compiler and CPU. With gcc 12.2.0 on Linux running on "znver3" hardware, performance for both UTF8 and non-UTF8 strings approximately doubled. Using clang-11 instead on the same machine gave a fivefold improvement for the non-UTF8 case. Commit: e792078d06516df587796501dcbe7d26e396faf1 https://github.com/Perl/perl5/commit/e792078d06516df587796501dcbe7d26e396faf1 Author: Richard Leach <richardle...@users.noreply.github.com> Date: 2025-03-12 (Wed, 12 Mar 2025) Changed paths: M pod/perldelta.pod Log Message: ----------- Perldelta for reverse string copies in one pass Compare: https://github.com/Perl/perl5/compare/9c5f1c44fd7a...e792078d0651 To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications