Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: New regex trick...

by japhy (Canon)
on Jul 22, 2002 at 19:33 UTC ( [id://184194]=note: print w/replies, xml ) Need Help??


in reply to Re: New regex trick...
in thread New regex trick...

Yours is a very special case, because we know there's only one character after the last ".". Here is a benchmark I ran with my new patch:
use Benchmark 'cmpthese'; my $str = join '.', 'a' .. 'z'; cmpthese(-5, { old => sub { (my $x = $str) =~ s/(.*)\..*/$1/ }, new => sub { (my $x = $str) =~ s/.*\K\..*// }, }); __END__ new: 109650.19/s (n=578953) old: 45258.35/s (n=241227)
... which is an incredible speed increase!

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://184194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found