- Issue created by @fgm
- last update
over 1 year ago 78 pass - @fgm opened merge request.
- Status changed to Fixed
over 1 year ago 8:48am 27 July 2023 Automatically closed - issue fixed for 2 weeks with no activity.
Currently, the regexp built for N matching patterns of length L has complexity (L+2)*N, but it could be 2+L*N instead.
Consider test case "A foo is a bar"
and patterns ['foo', 'bar']
as in MatcherTest::providerHandle
.
The regex101 debugger shows the two matches found after 38 steps and the conclusion of no third match 11 steps later, so 49 steps.
Move the word boundaries out of the individual matches in the capturing group.
The regex101 debugger shows the two matches found after 30 steps and the conclusion of no third match 6 steps later, so 36 steps vs 49 or a 27% reduction in work done. The saving is likely to be proportional to the number of matches.
Apply change, ensure it breaks no case.
None, test only.
None, test only.
None, test only.
Fixed
1.0
Code
Automatically closed - issue fixed for 2 weeks with no activity.