develooper Front page | perl.perl5.porters | Postings from May 2021

Re: Revisiting trim

Thread Previous | Thread Next
Paul "LeoNerd" Evans
May 27, 2021 20:17
Re: Revisiting trim
Message ID:
On Thu, 27 May 2021 21:13:35 +0200
demerphq <> wrote:

> Having said that, making the function return a result and not do
> inplace edit is a massive speed penalty and will likely mean that
> those using custom xs already to do this (my workplace) won't
> migrate. At least for us the point is to do it quickly, not to do it
> in a more self explanatory way.

The implementation already detects if target SV == source SV, and edits
in-place if that is the case.

  $str = trim $str;

will be an inplace edit.

Don't conflate "the user must write `trim $str` as a mutating keyword"
with "the implementation will mutate an existing SV inplace".

Paul "LeoNerd" Evans      |  |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About