in reply to Slow Regex - How to Optimize
I would use a different approach, i.e. make a single string from your @sub_code and apply the search for each key just once.
#untested my $code = join("", @sub_code); foreach my $sub ( keys %SUBS ) { while ( $code =~ /\b$sub\b\(/g ) { push( @subs, $sub ) ; } }
Notice that your code has a subtle bug. If the same routine is used twice in oone line, you'll get it only once. E.g.: sqrt(x) + sqrt(y)
BTW, what is that $key in your code?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Slow Regex - How to Optimize
by Anonymous Monk on Aug 30, 2005 at 23:16 UTC | |
by Anonymous Monk on Aug 30, 2005 at 23:30 UTC |