Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Speeding up a Perl code. Can it be faster?

by oiskuu (Hermit)
on Jun 10, 2016 at 15:42 UTC ( [id://1165302]=note: print w/replies, xml ) Need Help??


in reply to Speeding up a Perl code. Can it be faster?

It'd be helpful to know more of the specifics. For example, if the keys are limited to alphanumeric labels, the simplification could provide further speedup. Anyway, here's one regex-convoluted aka "adding problems to problems" version for your perusal:

sub uhuu { my $keys = join "|", map "\Q$_\E", ($match_list =~ m{([^/,]+)/[^,] +*}g); my %R; return unless $attrs =~ m{ \A \Q$tag\E \s+ (?: ($keys)=(\S+) (?(?{ defined $R{$1} || ($R{$1}=$2, 0) })(?! +)) \s* )*+ \z }x; $markup =~ s[X{($keys)}][ $R{$1} // $& ]ger }

A side-note to benchmarkers: localize the globals that you modify. ("On the importance of testing your testing.")

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-23 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found