Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: An optimization of last resort: eliminate capturing from your regexps

by Aristotle (Chancellor)
on Jul 24, 2006 at 22:04 UTC ( #563396=note: print w/ replies, xml ) Need Help??


in reply to Re: An optimization of last resort: eliminate capturing from your regexps
in thread An optimization of last resort: eliminate capturing from your regexps

If a pattern doesnít contain (?{}) or (??{}) bits, then $str cannot change during a match. So in that case it would be feasible to postpone the memcpy until right after the match (before the regex engine returns) and memcpy only the matched bits. That way, all regexen which donít run Perl code would automatically avoid unnecessary copying. I think that would be a worthwhile patch.

Makeshifts last the longest.


Comment on Re^2: An optimization of last resort: eliminate capturing from your regexps
Re^3: An optimization of last resort: eliminate capturing from your regexps
by diotalevi (Canon) on Jul 24, 2006 at 23:06 UTC

    I think that's what it does already.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      That would contradict tyeís explanation:

      Capturing in a regex imparts a performance hit because it means that a copy will be made of the string that the regex is being applied to (which makes it a worse performance hit when matching against really large strings Ė one of the worst cases being running a lot of little regexes with capturing against the same huge string, something a parser is likely to do).

      I donít see how what tye said would apply if perl already behaved the way I said it should.

      Makeshifts last the longest.

        Perl makes a copy if there is capturing or PL_saw_ampersand is true. I think you said that perl makes that copy immediately on partial success or similar. I responded saying that I think perl waits until the match has succeeded to make the copy. I don't think what I just said contradicts tye at all especially as tye is also right.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2014-12-19 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (77 votes), past polls