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

Re: Revisiting trim

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
May 27, 2021 20:17
Subject:
Re: Revisiting trim
Message ID:
20210527211655.6090eb1a@shy.leonerd.org.uk
On Thu, 27 May 2021 21:13:35 +0200
demerphq <demerphq@gmail.com> 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

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About