diff options
| author | Gregory Heytings | 2022-07-18 15:50:57 +0000 |
|---|---|---|
| committer | Gregory Heytings | 2022-07-18 17:54:55 +0200 |
| commit | 1ff69cc744eaa704afc1ff81242d41a6c09439fe (patch) | |
| tree | 3355dbbb1715b0661b1b0e7beaf5b0ef20f41eef /src | |
| parent | 6a097a86210cf1226d432b255cc41aa74fe93507 (diff) | |
| download | emacs-1ff69cc744eaa704afc1ff81242d41a6c09439fe.tar.gz emacs-1ff69cc744eaa704afc1ff81242d41a6c09439fe.zip | |
Improve the heuristic for long lines detection.
* src/buffer.h (struct buffer_text): New 'unchanged_size' field.
(BUF_UNCHANGED_SIZE): New macro to access the field.
* src/buffer.c (Fget_buffer_create): Initialize the field.
(Fbuffer_swap_text): Handle it.
* src/xdisp.c (mark_window_display_accurate_1): Set the field.
(redisplay_window): Use the field for long lines detection.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 6 | ||||
| -rw-r--r-- | src/buffer.h | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index a777668e44b..9a463363b93 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -599,6 +599,7 @@ even if it is dead. The return value is never nil. */) | |||
| 599 | BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; | 599 | BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; |
| 600 | BUF_END_UNCHANGED (b) = 0; | 600 | BUF_END_UNCHANGED (b) = 0; |
| 601 | BUF_BEG_UNCHANGED (b) = 0; | 601 | BUF_BEG_UNCHANGED (b) = 0; |
| 602 | BUF_UNCHANGED_SIZE (b) = 0; | ||
| 602 | *(BUF_GPT_ADDR (b)) = *(BUF_Z_ADDR (b)) = 0; /* Put an anchor '\0'. */ | 603 | *(BUF_GPT_ADDR (b)) = *(BUF_Z_ADDR (b)) = 0; /* Put an anchor '\0'. */ |
| 603 | b->text->inhibit_shrinking = false; | 604 | b->text->inhibit_shrinking = false; |
| 604 | b->text->redisplay = false; | 605 | b->text->redisplay = false; |
| @@ -2477,6 +2478,11 @@ results, see Info node `(elisp)Swapping Text'. */) | |||
| 2477 | other_buffer->text->beg_unchanged = other_buffer->text->gpt; | 2478 | other_buffer->text->beg_unchanged = other_buffer->text->gpt; |
| 2478 | other_buffer->text->end_unchanged = other_buffer->text->gpt; | 2479 | other_buffer->text->end_unchanged = other_buffer->text->gpt; |
| 2479 | { | 2480 | { |
| 2481 | ptrdiff_t tmp = current_buffer->text->unchanged_size; | ||
| 2482 | current_buffer->text->unchanged_size = other_buffer->text->unchanged_size; | ||
| 2483 | other_buffer->text->unchanged_size = tmp; | ||
| 2484 | } | ||
| 2485 | { | ||
| 2480 | struct Lisp_Marker *m; | 2486 | struct Lisp_Marker *m; |
| 2481 | for (m = BUF_MARKERS (current_buffer); m; m = m->next) | 2487 | for (m = BUF_MARKERS (current_buffer); m; m = m->next) |
| 2482 | if (m->buffer == other_buffer) | 2488 | if (m->buffer == other_buffer) |
diff --git a/src/buffer.h b/src/buffer.h index 09daa29992a..c2dca0a10c1 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -144,6 +144,9 @@ enum { BEG = 1, BEG_BYTE = BEG }; | |||
| 144 | #define BUF_UNCHANGED_MODIFIED(buf) \ | 144 | #define BUF_UNCHANGED_MODIFIED(buf) \ |
| 145 | ((buf)->text->unchanged_modified) | 145 | ((buf)->text->unchanged_modified) |
| 146 | 146 | ||
| 147 | #define BUF_UNCHANGED_SIZE(buf) \ | ||
| 148 | ((buf)->text->unchanged_size) | ||
| 149 | |||
| 147 | #define BUF_OVERLAY_UNCHANGED_MODIFIED(buf) \ | 150 | #define BUF_OVERLAY_UNCHANGED_MODIFIED(buf) \ |
| 148 | ((buf)->text->overlay_unchanged_modified) | 151 | ((buf)->text->overlay_unchanged_modified) |
| 149 | #define BUF_BEG_UNCHANGED(buf) ((buf)->text->beg_unchanged) | 152 | #define BUF_BEG_UNCHANGED(buf) ((buf)->text->beg_unchanged) |
| @@ -267,6 +270,9 @@ struct buffer_text | |||
| 267 | end_unchanged contain no useful information. */ | 270 | end_unchanged contain no useful information. */ |
| 268 | modiff_count overlay_unchanged_modified; | 271 | modiff_count overlay_unchanged_modified; |
| 269 | 272 | ||
| 273 | /* Buffer size as of last redisplay that finished. */ | ||
| 274 | ptrdiff_t unchanged_size; | ||
| 275 | |||
| 270 | /* Properties of this buffer's text. */ | 276 | /* Properties of this buffer's text. */ |
| 271 | INTERVAL intervals; | 277 | INTERVAL intervals; |
| 272 | 278 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index 572ad2b8540..375158a5204 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -17074,6 +17074,7 @@ mark_window_display_accurate_1 (struct window *w, bool accurate_p) | |||
| 17074 | BUF_OVERLAY_UNCHANGED_MODIFIED (b) = BUF_OVERLAY_MODIFF (b); | 17074 | BUF_OVERLAY_UNCHANGED_MODIFIED (b) = BUF_OVERLAY_MODIFF (b); |
| 17075 | BUF_BEG_UNCHANGED (b) = BUF_GPT (b) - BUF_BEG (b); | 17075 | BUF_BEG_UNCHANGED (b) = BUF_GPT (b) - BUF_BEG (b); |
| 17076 | BUF_END_UNCHANGED (b) = BUF_Z (b) - BUF_GPT (b); | 17076 | BUF_END_UNCHANGED (b) = BUF_Z (b) - BUF_GPT (b); |
| 17077 | BUF_UNCHANGED_SIZE (b) = BUF_Z (b) - BUF_BEG (b); | ||
| 17077 | 17078 | ||
| 17078 | w->current_matrix->buffer = b; | 17079 | w->current_matrix->buffer = b; |
| 17079 | w->current_matrix->begv = BUF_BEGV (b); | 17080 | w->current_matrix->begv = BUF_BEGV (b); |
| @@ -19279,7 +19280,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 19279 | /* Check whether the buffer to be displayed contains long lines. */ | 19280 | /* Check whether the buffer to be displayed contains long lines. */ |
| 19280 | if (!NILP (Vlong_line_threshold) | 19281 | if (!NILP (Vlong_line_threshold) |
| 19281 | && !current_buffer->long_line_optimizations_p | 19282 | && !current_buffer->long_line_optimizations_p |
| 19282 | && MODIFF != UNCHANGED_MODIFIED) | 19283 | && Z - BEG - BUF_UNCHANGED_SIZE (current_buffer) <= 1) |
| 19283 | { | 19284 | { |
| 19284 | ptrdiff_t cur, next, found, max = 0; | 19285 | ptrdiff_t cur, next, found, max = 0; |
| 19285 | for (cur = 1; cur < Z; cur = next) | 19286 | for (cur = 1; cur < Z; cur = next) |