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

Re: Revisiting trim

Thread Previous | Thread Next
From:
demerphq
Date:
May 28, 2021 07:27
Subject:
Re: Revisiting trim
Message ID:
CANgJU+XDZ__BS-o3h0yquAAc_0qp_dYCaoXBy2voOtfF7CT5NA@mail.gmail.com
On Thu, 27 May 2021 at 22:17, Paul "LeoNerd" Evans
<leonerd@leonerd.org.uk> wrote:
>
> 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".

Ah, so that would be this implementation is hairier than it would need
to be if the argument was modified in place without this type of
detection, it also explains one of your other comments that didnt make
sense to me.

Thanks,

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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