aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-09-01 18:43:30 +0000
committerRichard M. Stallman1995-09-01 18:43:30 +0000
commitae4788a82befc4d0903e349e0df2f8038e8b6ac5 (patch)
tree39c7b7d7e33100db678995e998044d8276c0f595 /src
parentaea4a109af0f37a139c63a0cf86512437612030a (diff)
downloademacs-ae4788a82befc4d0903e349e0df2f8038e8b6ac5.tar.gz
emacs-ae4788a82befc4d0903e349e0df2f8038e8b6ac5.zip
(re_search_2): If pattern starts with \=, optimize search.
Diffstat (limited to 'src')
-rw-r--r--src/regex.c20
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)
3036 case at_dot: 3036 case at_dot:
3037 case after_dot: 3037 case after_dot:
3038 continue; 3038 continue;
3039#endif /* not emacs */ 3039#endif /* emacs */
3040 3040
3041 3041
3042 case no_op: 3042 case no_op:
@@ -3275,6 +3275,17 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
3275 range = 1; 3275 range = 1;
3276 } 3276 }
3277 3277
3278#ifdef emacs
3279 /* In a forward search for something that starts with \=.
3280 don't keep searching past point. */
3281 if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0)
3282 {
3283 range = PT - startpos;
3284 if (range <= 0)
3285 return -1;
3286 }
3287#endif /* emacs */
3288
3278 /* Update the fastmap now if not correct already. */ 3289 /* Update the fastmap now if not correct already. */
3279 if (fastmap && !bufp->fastmap_accurate) 3290 if (fastmap && !bufp->fastmap_accurate)
3280 if (re_compile_fastmap (bufp) == -2) 3291 if (re_compile_fastmap (bufp) == -2)
@@ -4678,13 +4689,6 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
4678 if (PTR_CHAR_POS ((unsigned char *) d) <= point) 4689 if (PTR_CHAR_POS ((unsigned char *) d) <= point)
4679 goto fail; 4690 goto fail;
4680 break; 4691 break;
4681#if 0 /* not emacs19 */
4682 case at_dot:
4683 DEBUG_PRINT1 ("EXECUTING at_dot.\n");
4684 if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point)
4685 goto fail;
4686 break;
4687#endif /* not emacs19 */
4688 4692
4689 case syntaxspec: 4693 case syntaxspec:
4690 DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); 4694 DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);