emacs-diffs
[Top][All Lists]
Advanced

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

feature/long-lines-improvements 82b602dc2f: Improve Bidi with long lines


From: Gregory Heytings
Subject: feature/long-lines-improvements 82b602dc2f: Improve Bidi with long lines.
Date: Thu, 4 Aug 2022 05:08:41 -0400 (EDT)

branch: feature/long-lines-improvements
commit 82b602dc2f52775a4082d24d64380867da051350
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    Improve Bidi with long lines.
    
    * src/composite.c (composition_compute_stop_pos): Use an 'endpos' that
    is not too far away.
    (find_automatic_composition): Use a 'head' that is not too far away.
    Also make sure that this code path is not taken when long line
    optimizations are disabled.
    
    * src/dispextern.h (struct composition_it): Add a field that points
    to the parent iterator.
    
    * src/xdisp.c (init_iterator): Set it.
---
 src/composite.c  | 20 +++++++++++++-------
 src/dispextern.h |  2 ++
 src/xdisp.c      |  1 +
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/composite.c b/src/composite.c
index e721fe8c81..9e641722ca 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1021,7 +1021,11 @@ composition_compute_stop_pos (struct composition_it 
*cmp_it, ptrdiff_t charpos,
          /* But we don't know where to stop the searching.  */
          endpos = NILP (string) ? BEGV - 1 : -1;
          /* Usually we don't reach ENDPOS because we stop searching
-            at an uncomposable character (NL, LRE, etc).  */
+            at an uncomposable character (NL, LRE, etc).  In buffers
+            with long lines, however, NL might be far away, so
+            pretend that the buffer is smaller.  */
+         if (current_buffer->long_line_optimizations_p)
+           endpos = get_closer_narrowed_begv (cmp_it->parent_it->w, charpos);
        }
     }
   cmp_it->id = -1;
@@ -1580,7 +1584,6 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t 
limit, ptrdiff_t backlim,
   Lisp_Object window;
   struct window *w;
   bool need_adjustment = 0;
-  ptrdiff_t narrowed_begv;
 
   window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
   if (NILP (window))
@@ -1597,11 +1600,14 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t 
limit, ptrdiff_t backlim,
        }
       else
        head = backlim;
-      /* In buffers with very long lines, this function becomes very
-        slow.  Pretend that the buffer is narrowed to make it fast.  */
-      narrowed_begv = get_narrowed_begv (w, window_point (w));
-      if (pos > narrowed_begv)
-       head = narrowed_begv;
+      if (current_buffer->long_line_optimizations_p)
+       {
+         /* In buffers with very long lines, this function becomes very
+            slow.  Pretend that the buffer is narrowed to make it fast.  */
+         ptrdiff_t begv = get_closer_narrowed_begv (w, window_point (w));
+         if (pos > begv)
+           head = narrowed_begv;
+       }
       tail = ZV;
       stop = GPT;
       cur.pos_byte = CHAR_TO_BYTE (cur.pos);
diff --git a/src/dispextern.h b/src/dispextern.h
index 037e02ff58..12ba927261 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2287,6 +2287,8 @@ struct composition_it
      reverse order, and thus the grapheme clusters must be rendered
      from the last to the first.  */
   bool reversed_p;
+  /* Parent iterator. */
+  struct it *parent_it;
 
   /** The following members contain information about the current
       grapheme cluster.  */
diff --git a/src/xdisp.c b/src/xdisp.c
index 7d62c7823e..12f56227e4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3229,6 +3229,7 @@ init_iterator (struct it *it, struct window *w,
   it->f = XFRAME (w->frame);
 
   it->cmp_it.id = -1;
+  it->cmp_it.parent_it = it;
 
   if (max_redisplay_ticks > 0)
     update_redisplay_ticks (0, w);



reply via email to

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