Your code is likely buggy. You've passed in read-only values to $this->mask_block_params(...) and you have no idea that $` and $' are still valid by the time you use them. Here's an alternate reformulation which also avoids incurring the $`, $&, $' speed penalties. If this is your only use of $`, $&, and $', you may find a nice speed improvement.
while ($this->{template} =~ /$re/) { # Uses substr and @-/@+ instead of $` and $'. Also is sure to capt +ure those values before executing other potentially regex-using code. my ( $prior, $start, $close, $after ) = = ( substr( $this->{template}, 0, $-[0] ), $1, $2, substr( $this->{template}, $+[0] ) ); my $params = $this->mask_block_params( $start, $close ); my $html = &$callback($key, $params); $this->{template} = $prior . $html . $after; }
In reply to Re: Regex speed issue
by diotalevi
in thread Regex speed issue
by mtsachev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |