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

Re: Revisiting trim

Thread Previous | Thread Next
May 28, 2021 07:27
Re: Revisiting trim
Message ID:
On Thu, 27 May 2021 at 22:17, Paul "LeoNerd" Evans
<> wrote:
> 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".

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.



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

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