+2011-07-16 Eli Zaretskii <eliz@gnu.org>
+
+ * xdisp.c <cached_disp_pos, cached_disp_buffer, cached_disp_modiff>:
+ Cache for last found display string position.
+ (compute_display_string_pos): Return the cached position if asked
+ about the same buffer.
+
2011-07-14 Eli Zaretskii <eliz@gnu.org>
* bidi.c (bidi_cache_fetch_state, bidi_cache_search)
return endpos;
}
+/* Record one cached display string position found recently by
+ compute_display_string_pos. */
+static EMACS_INT cached_disp_pos;
+static struct buffer *cached_disp_buffer;
+static int cached_disp_modiff;
+
/* Return the character position of a display string at or after
position specified by POSITION. If no display string exists at or
after POSITION, return ZV. A display string is either an overlay
EMACS_INT begb = string_p ? 0 : BEGV;
EMACS_INT bufpos, charpos = CHARPOS (*position);
struct text_pos tpos;
+ struct buffer *b;
if (charpos >= eob
/* We don't support display properties whose values are strings
|| (string->s && !STRINGP (object)))
return eob;
+ /* Check the cached values. */
+ if (!STRINGP (object))
+ {
+ if (NILP (object))
+ b = current_buffer;
+ else
+ b = XBUFFER (object);
+ if (b == cached_disp_buffer
+ && BUF_MODIFF (b) == cached_disp_modiff
+ && charpos <= cached_disp_pos)
+ return cached_disp_pos;
+
+ /* Record new values in the cache. */
+ cached_disp_buffer = b;
+ cached_disp_modiff = BUF_MODIFF (b);
+ }
+
/* If the character at CHARPOS is where the display string begins,
return CHARPOS. */
pos = make_number (charpos);
spec))
&& handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
frame_window_p))
- return charpos;
+ {
+ if (!STRINGP (object))
+ cached_disp_pos = charpos;
+ return charpos;
+ }
/* Look forward for the first character with a `display' property
that will replace the underlying text when displayed. */
|| !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
frame_window_p));
+ if (!STRINGP (object))
+ cached_disp_pos = CHARPOS (tpos);
return CHARPOS (tpos);
}