in reply to Re^2: regex problem
in thread regex problem
Someone recently estimated to me in a BOTE calculation that [ ] is 10x slower. That is, this hamstrings the screamingly fast boyer-moore literal string matching part of the regex engine and compiles /xxx[ ]xxx/ down to exact("xxx"), anyof(" "), exact("xxx") where it was originally exact( "xxx xxx" ).
You've changed the regex from one for a seven character literal to one that contains two three character literals. That changes how the engine matches and it changes how quickly the BM part of the engine can either discard entirely or find suitable candidates. It also causes more overhead because three ops have to be executed instead of just one.
I'm asserting that [ ] is pretty to look at but has serious consequences to the regexp's performance. I wouldn't ordinarilly choose the pretty version in that case. I rarely ever use /x though so I don't need to escape my spaces.
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: regex problem
by QM (Parson) on Feb 27, 2006 at 23:38 UTC | |
by diotalevi (Canon) on Feb 27, 2006 at 23:40 UTC |