diff options
| author | Stefan Monnier | 2023-09-28 12:37:44 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2023-09-28 12:37:44 -0400 |
| commit | 7c26501175f7dc657c677c151d49d04291ea67e7 (patch) | |
| tree | 1e0e7be5a4ffcba27924243f960de7cc8d79613b /src | |
| parent | 0c15c7d9467f33ccc317296af00440b37569c703 (diff) | |
| download | emacs-7c26501175f7dc657c677c151d49d04291ea67e7.tar.gz emacs-7c26501175f7dc657c677c151d49d04291ea67e7.zip | |
regex.c (mutually_exclusive_aux) <wordbound>: Remove optimization
Another case that was too optimistic. Better use \> or \< rather
than \b if you want your regexp to be handled efficiently.
* src/regex-emacs.c (mutually_exclusive_aux) <wordbound>: Cancel optimization.
* test/src/regex-emacs-tests.el (regexp-tests-backtrack-optimization):
New test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex-emacs.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/regex-emacs.c b/src/regex-emacs.c index ae82dd63917..ad140908609 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c | |||
| @@ -3874,9 +3874,22 @@ mutually_exclusive_aux (struct re_pattern_buffer *bufp, re_char *p1, | |||
| 3874 | return ((re_opcode_t) *p1 == notsyntaxspec && p1[1] == p2[1]); | 3874 | return ((re_opcode_t) *p1 == notsyntaxspec && p1[1] == p2[1]); |
| 3875 | 3875 | ||
| 3876 | case wordbound: | 3876 | case wordbound: |
| 3877 | /* FIXME: This optimization seems correct after the first iteration | ||
| 3878 | of the loop, but not for the very first :-( | ||
| 3879 | IOW we'd need to pull out the first iteration and do: | ||
| 3880 | |||
| 3881 | syntaxspec w | ||
| 3882 | on_failure_keep_string_jump end | ||
| 3883 | loop: | ||
| 3884 | syntaxspec w | ||
| 3885 | goto loop | ||
| 3886 | end: | ||
| 3887 | wordbound | ||
| 3888 | |||
| 3877 | return (((re_opcode_t) *p1 == notsyntaxspec | 3889 | return (((re_opcode_t) *p1 == notsyntaxspec |
| 3878 | || (re_opcode_t) *p1 == syntaxspec) | 3890 | || (re_opcode_t) *p1 == syntaxspec) |
| 3879 | && p1[1] == Sword); | 3891 | && p1[1] == Sword); */ |
| 3892 | return false; | ||
| 3880 | 3893 | ||
| 3881 | case categoryspec: | 3894 | case categoryspec: |
| 3882 | return ((re_opcode_t) *p1 == notcategoryspec && p1[1] == p2[1]); | 3895 | return ((re_opcode_t) *p1 == notcategoryspec && p1[1] == p2[1]); |