aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2011-07-24 21:19:10 +0300
committerEli Zaretskii <[email protected]>2011-07-24 21:19:10 +0300
commit7daee9109e1d69d62528f6b460d101e1ea44f4e1 (patch)
tree25d2f5c26d858e440c8e0d105c40a0347f22b46f
parent8719d1dcad924e8b00b8610cbb531fcef5fca0b5 (diff)
Fix cursor motion slowdown at the beginning of buffer.
src/xdisp.c (compute_display_string_pos): Fix logic of caching previous display string position. Initialize cached_prev_pos to -1.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xdisp.c12
2 files changed, 14 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index dd5a1fba87..8aa1237f69 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2011-07-24 Eli Zaretskii <[email protected]>
+
+ * xdisp.c (compute_display_string_pos): Fix logic of caching
+ previous display string position. Initialize cached_prev_pos to
+ -1. Fixes slow-down at the beginning of a buffer.
+
2011-07-23 Eli Zaretskii <[email protected]>
* xdisp.c (move_it_in_display_line_to): Record the best matching
diff --git a/src/xdisp.c b/src/xdisp.c
index a5eb2aa923..5f9e80cd11 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3140,7 +3140,7 @@ next_overlay_change (EMACS_INT pos)
/* Record one cached display string position found recently by
compute_display_string_pos. */
static EMACS_INT cached_disp_pos;
-static EMACS_INT cached_prev_pos;
+static EMACS_INT cached_prev_pos = -1;
static struct buffer *cached_disp_buffer;
static int cached_disp_modiff;
static int cached_disp_overlay_modiff;
@@ -3190,18 +3190,22 @@ compute_display_string_pos (struct text_pos *position,
&& BUF_MODIFF (b) == cached_disp_modiff
&& BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff)
{
- if (cached_prev_pos
+ if (cached_prev_pos >= 0
&& cached_prev_pos < charpos && charpos <= cached_disp_pos)
return cached_disp_pos;
/* Handle overstepping either end of the known interval. */
if (charpos > cached_disp_pos)
cached_prev_pos = cached_disp_pos;
else /* charpos <= cached_prev_pos */
- cached_prev_pos = max (charpos - 1, BEGV);
+ cached_prev_pos = max (charpos - 1, 0);
}
/* Record new values in the cache. */
- cached_disp_buffer = b;
+ if (b != cached_disp_buffer)
+ {
+ cached_disp_buffer = b;
+ cached_prev_pos = max (charpos - 1, 0);
+ }
cached_disp_modiff = BUF_MODIFF (b);
cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b);
}