diff options
| author | Eli Zaretskii | 2011-07-24 21:19:10 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-07-24 21:19:10 +0300 |
| commit | 7daee9109e1d69d62528f6b460d101e1ea44f4e1 (patch) | |
| tree | 25d2f5c26d858e440c8e0d105c40a0347f22b46f | |
| parent | 8719d1dcad924e8b00b8610cbb531fcef5fca0b5 (diff) | |
| download | emacs-7daee9109e1d69d62528f6b460d101e1ea44f4e1.tar.gz emacs-7daee9109e1d69d62528f6b460d101e1ea44f4e1.zip | |
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/ChangeLog | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index dd5a1fba871..8aa1237f693 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-07-24 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (compute_display_string_pos): Fix logic of caching | ||
| 4 | previous display string position. Initialize cached_prev_pos to | ||
| 5 | -1. Fixes slow-down at the beginning of a buffer. | ||
| 6 | |||
| 1 | 2011-07-23 Eli Zaretskii <eliz@gnu.org> | 7 | 2011-07-23 Eli Zaretskii <eliz@gnu.org> |
| 2 | 8 | ||
| 3 | * xdisp.c (move_it_in_display_line_to): Record the best matching | 9 | * xdisp.c (move_it_in_display_line_to): Record the best matching |
diff --git a/src/xdisp.c b/src/xdisp.c index a5eb2aa923a..5f9e80cd11e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3140,7 +3140,7 @@ next_overlay_change (EMACS_INT pos) | |||
| 3140 | /* Record one cached display string position found recently by | 3140 | /* Record one cached display string position found recently by |
| 3141 | compute_display_string_pos. */ | 3141 | compute_display_string_pos. */ |
| 3142 | static EMACS_INT cached_disp_pos; | 3142 | static EMACS_INT cached_disp_pos; |
| 3143 | static EMACS_INT cached_prev_pos; | 3143 | static EMACS_INT cached_prev_pos = -1; |
| 3144 | static struct buffer *cached_disp_buffer; | 3144 | static struct buffer *cached_disp_buffer; |
| 3145 | static int cached_disp_modiff; | 3145 | static int cached_disp_modiff; |
| 3146 | static int cached_disp_overlay_modiff; | 3146 | static int cached_disp_overlay_modiff; |
| @@ -3190,18 +3190,22 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3190 | && BUF_MODIFF (b) == cached_disp_modiff | 3190 | && BUF_MODIFF (b) == cached_disp_modiff |
| 3191 | && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff) | 3191 | && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff) |
| 3192 | { | 3192 | { |
| 3193 | if (cached_prev_pos | 3193 | if (cached_prev_pos >= 0 |
| 3194 | && cached_prev_pos < charpos && charpos <= cached_disp_pos) | 3194 | && cached_prev_pos < charpos && charpos <= cached_disp_pos) |
| 3195 | return cached_disp_pos; | 3195 | return cached_disp_pos; |
| 3196 | /* Handle overstepping either end of the known interval. */ | 3196 | /* Handle overstepping either end of the known interval. */ |
| 3197 | if (charpos > cached_disp_pos) | 3197 | if (charpos > cached_disp_pos) |
| 3198 | cached_prev_pos = cached_disp_pos; | 3198 | cached_prev_pos = cached_disp_pos; |
| 3199 | else /* charpos <= cached_prev_pos */ | 3199 | else /* charpos <= cached_prev_pos */ |
| 3200 | cached_prev_pos = max (charpos - 1, BEGV); | 3200 | cached_prev_pos = max (charpos - 1, 0); |
| 3201 | } | 3201 | } |
| 3202 | 3202 | ||
| 3203 | /* Record new values in the cache. */ | 3203 | /* Record new values in the cache. */ |
| 3204 | cached_disp_buffer = b; | 3204 | if (b != cached_disp_buffer) |
| 3205 | { | ||
| 3206 | cached_disp_buffer = b; | ||
| 3207 | cached_prev_pos = max (charpos - 1, 0); | ||
| 3208 | } | ||
| 3205 | cached_disp_modiff = BUF_MODIFF (b); | 3209 | cached_disp_modiff = BUF_MODIFF (b); |
| 3206 | cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b); | 3210 | cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b); |
| 3207 | } | 3211 | } |