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

Re: Benchmarking Pure Perl Trim Functions.

Thread Previous | Thread Next
From:
demerphq
Date:
June 4, 2021 13:30
Subject:
Re: Benchmarking Pure Perl Trim Functions.
Message ID:
CANgJU+Xo50Xj7V6Jpv1846SH08LZ5J7eScM4qcfhE020434i5Q@mail.gmail.com
On Fri, 4 Jun 2021 at 03:06, <hv@crypt.org> wrote:

> Nicholas Clark <nick@ccl4.org> wrote:
> :More - I assumed that the regexes used to "trim spaces from the right" are
> :
> :1) simple to recognise
> :2) there aren't that many variations of them
> :
> :So I set off with the goal of recognising them in the regex compiler, and
> :then having re_intuit_start() implement them better.
> :
> :In the branch https://github.com/nwc10/perl5/tree/intiuit-rtrim


Nicholas: Very Interesting. Similar to the stuff  i did with split. I like.
But I think i missed support for:

s/\s+\z//
s/\s*\z//
s/[\s+]\z//

etc. FWIW I am not sure how sane this approach is for THIS problem but its
worth seeing how far you can take it, and I definitely think it could work.
:-)

BTW, Hugo: the trie code is totally capable of building a machine  that we
could use to match /foo\z/ *from the right*, if we wished to do so.
Constructing a DFA to match from the right is pretty much the same as
constructing a DFA from the left, and the trie code just implements a
non-cyclic DFA.

I generate such a machine in the perl code in
https://github.com/demerphq/DFA-Trim/blob/master/ctrie.pl

That perl code is a baby version of what  the trie code does in C in the
regex engine.

Yves

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