You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments