comparison src/search.c @ 73232:5f8a28d018b2

(compile_pattern): Only check `cp->syntax_table' if needed. (compile_pattern_1): Remember `used_syntax' in `cp->syntax_table'. (clear_regexp_cache): Only flush those regexps which depend on a syntax-table.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 03 Oct 2006 13:47:26 +0000
parents 20801e603746
children 94626132135d 8dd8c8286063
comparison
equal deleted inserted replaced
73231:6b368d6ebfa5 73232:5f8a28d018b2
214 cp->buf.buffer 214 cp->buf.buffer
215 = (unsigned char *) xrealloc (cp->buf.buffer, cp->buf.used); 215 = (unsigned char *) xrealloc (cp->buf.buffer, cp->buf.used);
216 } 216 }
217 } 217 }
218 218
219 /* Clear the regexp cache. 219 /* Clear the regexp cache w.r.t. a particular syntax table,
220 because it was changed.
220 There is no danger of memory leak here because re_compile_pattern 221 There is no danger of memory leak here because re_compile_pattern
221 automagically manages the memory in each re_pattern_buffer struct, 222 automagically manages the memory in each re_pattern_buffer struct,
222 based on its `allocated' and `buffer' values. */ 223 based on its `allocated' and `buffer' values. */
223 void 224 void
224 clear_regexp_cache () 225 clear_regexp_cache ()
225 { 226 {
226 int i; 227 int i;
227 228
228 for (i = 0; i < REGEXP_CACHE_SIZE; ++i) 229 for (i = 0; i < REGEXP_CACHE_SIZE; ++i)
229 searchbufs[i].regexp = Qnil; 230 /* It's tempting to compare with the syntax-table we've actually changd,
231 but it's not sufficient because char-table inheritance mewans that
232 modifying one syntax-table can change others at the same time. */
233 if (!EQ (searchbufs[i].syntax_table, Qt))
234 searchbufs[i].regexp = Qnil;
230 } 235 }
231 236
232 /* Compile a regexp if necessary, but first check to see if there's one in 237 /* Compile a regexp if necessary, but first check to see if there's one in
233 the cache. 238 the cache.
234 PATTERN is the pattern to compile. 239 PATTERN is the pattern to compile.