emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/fix-the-long-lines-display-bug c7eef61eee: Further tweaks to lon


From: Gregory Heytings
Subject: feature/fix-the-long-lines-display-bug c7eef61eee: Further tweaks to long lines handling.
Date: Wed, 20 Jul 2022 13:15:33 -0400 (EDT)

branch: feature/fix-the-long-lines-display-bug
commit c7eef61eee179d127d4edeb828c723f4dee530b4
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    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.
---
 etc/NEWS     | 6 +++---
 src/buffer.c | 2 +-
 src/buffer.h | 7 ++++---
 src/lisp.h   | 3 +++
 src/xdisp.c  | 2 +-
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 45efe2a08e..2217960381 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -330,9 +330,9 @@ The display of long lines has been optimized, and Emacs no 
longer
 chokes when a buffer on display contains long lines.  If you still
 experience slowdowns while editing files with long lines, this is
 either due to font locking, which you can turn off with M-x
-font-lock-mode, or to the current major mode or one of the enabled
-minor modes, in which case you should open the the file with M-x
-find-file-literally instead of C-x C-f.  The variable
+font-lock-mode or C-u C-x x f, or to the current major mode or one of
+the enabled minor modes, in which case you should open the the file
+with M-x find-file-literally instead of C-x C-f.  The variable
 'long-line-threshold' controls whether and when these display
 optimizations are used.
 
diff --git a/src/buffer.c b/src/buffer.c
index edd85d8ef6..d8964180cf 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4010,7 +4010,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, 
ptrdiff_t end)
 
   bset_redisplay (buf);
 
-  modiff_incr (&BUF_OVERLAY_MODIFF (buf), end - start);
+  modiff_incr (&BUF_OVERLAY_MODIFF (buf), 1);
 }
 
 /* Remove OVERLAY from LIST.  */
diff --git a/src/buffer.h b/src/buffer.h
index 09daa29992..47b4bdf749 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -237,9 +237,10 @@ struct buffer_text
     ptrdiff_t z_byte;          /* Byte pos of end of buffer.  */
     ptrdiff_t gap_size;                /* Size of buffer's gap.  */
     modiff_count modiff;       /* This counts buffer-modification events
-                                  for this buffer.  It is incremented for
-                                  each such event, and never otherwise
-                                  changed.  */
+                                  for this buffer.  It is increased
+                                  logarithmically to the extent of the
+                                  modification for each such event,
+                                  and never otherwise changed.  */
     modiff_count chars_modiff; /* This is modified with character change
                                   events for this buffer.  It is set to
                                   modiff for each such event, and never
diff --git a/src/lisp.h b/src/lisp.h
index 6e8c2f3a2f..dabf013d53 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3914,6 +3914,9 @@ INLINE modiff_count
 modiff_incr (modiff_count *a, ptrdiff_t len)
 {
   modiff_count a0 = *a; int incr = len ? 1 : 0;
+  /* Increase the counter more for a large modification and less for a
+     small modification.  Increase it logarithmically to avoid
+     increasing it too much.  */
   while (len >>= 1) incr++;
   bool modiff_overflow = INT_ADD_WRAPV (a0, incr, a);
   eassert (!modiff_overflow && *a >> 30 >> 30 == 0);
diff --git a/src/xdisp.c b/src/xdisp.c
index b1c492fab3..4701e2b245 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -19293,7 +19293,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
   /* Check whether the buffer to be displayed contains long lines.  */
   if (!NILP (Vlong_line_threshold)
       && !current_buffer->long_line_optimizations_p
-      && MODIFF - UNCHANGED_MODIFIED > 4)
+      && MODIFF - UNCHANGED_MODIFIED > 8)
     {
       ptrdiff_t cur, next, found, max = 0;
       for (cur = 1; cur < Z; cur = next)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]