aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGregory Heytings2022-07-20 17:12:23 +0000
committerGregory Heytings2022-07-20 19:14:41 +0200
commitc7eef61eee179d127d4edeb828c723f4dee530b4 (patch)
tree71e1f6978c0f0828f03aa781e9244e39f8c6618b /src
parent7c0fc853649c7e203814295de32357cfd6a336a9 (diff)
downloademacs-c7eef61eee179d127d4edeb828c723f4dee530b4.tar.gz
emacs-c7eef61eee179d127d4edeb828c723f4dee530b4.zip
Further tweaks to long lines handling.
* src/xdisp.c (redisplay_window): Increase the threshold above which long lines detection is performed in the buffer. This should avoid triggering that detection for most simple editing operations. * src/lisp.h (modiff_incr): Explain why the counter is incremented logarithmically. * src/buffer.h (struct buffer_text): Adapt the comment about the 'modiff' field accordingly. * src/buffer.c (modify_overlay): Increase the counter by 1 instead of the size of the buffer section on which the overlay is placed. * etc/NEWS: Small improvement.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c2
-rw-r--r--src/buffer.h7
-rw-r--r--src/lisp.h3
-rw-r--r--src/xdisp.c2
4 files changed, 9 insertions, 5 deletions
diff --git a/src/buffer.c b/src/buffer.c
index edd85d8ef63..d8964180cff 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4010,7 +4010,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
4010 4010
4011 bset_redisplay (buf); 4011 bset_redisplay (buf);
4012 4012
4013 modiff_incr (&BUF_OVERLAY_MODIFF (buf), end - start); 4013 modiff_incr (&BUF_OVERLAY_MODIFF (buf), 1);
4014} 4014}
4015 4015
4016/* Remove OVERLAY from LIST. */ 4016/* Remove OVERLAY from LIST. */
diff --git a/src/buffer.h b/src/buffer.h
index 09daa29992a..47b4bdf749b 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -237,9 +237,10 @@ struct buffer_text
237 ptrdiff_t z_byte; /* Byte pos of end of buffer. */ 237 ptrdiff_t z_byte; /* Byte pos of end of buffer. */
238 ptrdiff_t gap_size; /* Size of buffer's gap. */ 238 ptrdiff_t gap_size; /* Size of buffer's gap. */
239 modiff_count modiff; /* This counts buffer-modification events 239 modiff_count modiff; /* This counts buffer-modification events
240 for this buffer. It is incremented for 240 for this buffer. It is increased
241 each such event, and never otherwise 241 logarithmically to the extent of the
242 changed. */ 242 modification for each such event,
243 and never otherwise changed. */
243 modiff_count chars_modiff; /* This is modified with character change 244 modiff_count chars_modiff; /* This is modified with character change
244 events for this buffer. It is set to 245 events for this buffer. It is set to
245 modiff for each such event, and never 246 modiff for each such event, and never
diff --git a/src/lisp.h b/src/lisp.h
index 6e8c2f3a2f9..dabf013d531 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3914,6 +3914,9 @@ INLINE modiff_count
3914modiff_incr (modiff_count *a, ptrdiff_t len) 3914modiff_incr (modiff_count *a, ptrdiff_t len)
3915{ 3915{
3916 modiff_count a0 = *a; int incr = len ? 1 : 0; 3916 modiff_count a0 = *a; int incr = len ? 1 : 0;
3917 /* Increase the counter more for a large modification and less for a
3918 small modification. Increase it logarithmically to avoid
3919 increasing it too much. */
3917 while (len >>= 1) incr++; 3920 while (len >>= 1) incr++;
3918 bool modiff_overflow = INT_ADD_WRAPV (a0, incr, a); 3921 bool modiff_overflow = INT_ADD_WRAPV (a0, incr, a);
3919 eassert (!modiff_overflow && *a >> 30 >> 30 == 0); 3922 eassert (!modiff_overflow && *a >> 30 >> 30 == 0);
diff --git a/src/xdisp.c b/src/xdisp.c
index b1c492fab3a..4701e2b2459 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -19293,7 +19293,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
19293 /* Check whether the buffer to be displayed contains long lines. */ 19293 /* Check whether the buffer to be displayed contains long lines. */
19294 if (!NILP (Vlong_line_threshold) 19294 if (!NILP (Vlong_line_threshold)
19295 && !current_buffer->long_line_optimizations_p 19295 && !current_buffer->long_line_optimizations_p
19296 && MODIFF - UNCHANGED_MODIFIED > 4) 19296 && MODIFF - UNCHANGED_MODIFIED > 8)
19297 { 19297 {
19298 ptrdiff_t cur, next, found, max = 0; 19298 ptrdiff_t cur, next, found, max = 0;
19299 for (cur = 1; cur < Z; cur = next) 19299 for (cur = 1; cur < Z; cur = next)