in reply to tight loop regex optimization
You're only going to some limited benefit by tweaking the regex patterns. Shaving 20% off of 60 seconds is still 48 seconds.
One thing I see is that you're scanning the file from to to bottom for each s/// operator, and often more than once per pattern. Your efforts might be better spent avoid that. Some examples are self contained,
while ($contents =~ s/\05([^\n\05]+)\05/$1\05\05/gs) {} | | v $contents =~ s/\05([^\n\05]+)(?=\05)/$1\05/gs;
But that's not going to help you remove this waste in general.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: tight loop regex optimization
by superawesome (Initiate) on Nov 02, 2011 at 05:08 UTC | |
by ikegami (Patriarch) on Nov 02, 2011 at 05:29 UTC |