Mercurial > emacs
changeset 27592:5cd59d1800ad
* search.c (compile_pattern): If a cache entry has a nil regexp, fill in that
entry instead of clobbering a previously cached string regexp.
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Thu, 03 Feb 2000 07:54:12 +0000 |
parents | 459744c91b53 |
children | f66d3f31c03e |
files | src/ChangeLog src/search.c |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/search.c Wed Feb 02 21:06:43 2000 +0000 +++ b/src/search.c Thu Feb 03 07:54:12 2000 +0000 @@ -219,6 +219,13 @@ 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 @@ && 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; }