diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-09-01 18:43:30 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-09-01 18:43:30 +0000 |
commit | 08b57c47c57c84748ad9ee47a4b2b101d1368ef5 (patch) | |
tree | 9cf9d4446d65b7f3d44467613f8b220e681d41e3 /src/regex.c | |
parent | c983d26bbe90967bc72e550c28e3898e55895167 (diff) | |
download | emacs-08b57c47c57c84748ad9ee47a4b2b101d1368ef5.tar.gz |
(re_search_2): If pattern starts with \=, optimize search.
Diffstat (limited to 'src/regex.c')
-rw-r--r-- | src/regex.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/regex.c b/src/regex.c index d497d895784..d0086ed1aad 100644 --- a/src/regex.c +++ b/src/regex.c @@ -3036,7 +3036,7 @@ re_compile_fastmap (bufp) case at_dot: case after_dot: continue; -#endif /* not emacs */ +#endif /* emacs */ case no_op: @@ -3275,6 +3275,17 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) range = 1; } +#ifdef emacs + /* In a forward search for something that starts with \=. + don't keep searching past point. */ + if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) + { + range = PT - startpos; + if (range <= 0) + return -1; + } +#endif /* emacs */ + /* Update the fastmap now if not correct already. */ if (fastmap && !bufp->fastmap_accurate) if (re_compile_fastmap (bufp) == -2) @@ -4678,13 +4689,6 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) if (PTR_CHAR_POS ((unsigned char *) d) <= point) goto fail; break; -#if 0 /* not emacs19 */ - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) - goto fail; - break; -#endif /* not emacs19 */ case syntaxspec: DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); |