From f1b9c7c1ce775f54c5a32c9c80c09584ccb3d7ca Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 3 Feb 2000 07:54:12 +0000 Subject: [PATCH] * search.c (compile_pattern): If a cache entry has a nil regexp, fill in that entry instead of clobbering a previously cached string regexp. --- src/ChangeLog | 6 ++++++ src/search.c | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index f3b41fcf188..5251578b710 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2000-02-03 Ken Raeburn + + * search.c (compile_pattern): If a cache entry has a nil regexp, + fill in that entry instead of clobbering a previously cached + string regexp. + 2000-02-02 Ken Raeburn * puresize.h (BASE_PURESIZE): Increase to 610000. diff --git a/src/search.c b/src/search.c index 5bcbaa615b3..3111548af58 100644 --- a/src/search.c +++ b/src/search.c @@ -219,6 +219,13 @@ compile_pattern (pattern, regp, translate, posix, multibyte) for (cpp = &searchbuf_head; ; cpp = &cp->next) { cp = *cpp; + /* Entries are initialized to nil, and may be set to nil by + compile_pattern_1 if the pattern isn't valid. Don't apply + XSTRING in those cases. However, compile_pattern_1 is only + applied to the cache entry we pick here to reuse. So nil + should never appear before a non-nil entry. */ + if (cp->regexp == Qnil) + goto compile_it; if (XSTRING (cp->regexp)->size == XSTRING (pattern)->size && !NILP (Fstring_equal (cp->regexp, pattern)) && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) @@ -226,9 +233,12 @@ compile_pattern (pattern, regp, translate, posix, multibyte) && cp->buf.multibyte == multibyte) break; - /* If we're at the end of the cache, compile into the last cell. */ + /* If we're at the end of the cache, compile into the nil cell + we found, or the last (least recently used) cell with a + string value. */ if (cp->next == 0) { + compile_it: compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte); break; } -- 2.39.5