emacs-diffs
[Top][All Lists]
Advanced

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

feature/long-lines-and-font-locking fc53961c1d: Avoid calling 'current_c


From: Eli Zaretskii
Subject: feature/long-lines-and-font-locking fc53961c1d: Avoid calling 'current_column' in buffers with long lines.
Date: Sat, 23 Jul 2022 10:44:39 -0400 (EDT)

branch: feature/long-lines-and-font-locking
commit fc53961c1df8bee07b6a1d461d31f449b66f1d65
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid calling 'current_column' in buffers with long lines.
    
    * src/xdisp.c (decode_mode_spec, redisplay_window)
    (mode_line_update_needed):
    * src/indent.c (Fcurrent_column): In a buffer with long-line
    optimizations enabled, avoid calling 'current_column', which is
    very slow in that case.
---
 src/indent.c | 5 +++++
 src/xdisp.c  | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/indent.c b/src/indent.c
index d4ef075f00..e90e3fde20 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -306,6 +306,8 @@ and point (e.g., control characters will have a width of 2 
or 4, tabs
 will have a variable width).
 Ignores finite width of frame, which means that this function may return
 values greater than (frame-width).
+In a buffer with very long lines, the value can be zero, because calculating
+the exact number is very expensive.
 Whether the line is visible (if `selective-display' is t) has no effect;
 however, ^M is treated as end of line when `selective-display' is t.
 Text that has an invisible property is considered as having width 0, unless
@@ -313,6 +315,9 @@ Text that has an invisible property is considered as having 
width 0, unless
   (void)
 {
   Lisp_Object temp;
+
+  if (current_buffer->long_line_optimizations_p)
+    return make_fixnum (0);
   XSETFASTINT (temp, current_column ());
   return temp;
 }
diff --git a/src/xdisp.c b/src/xdisp.c
index 690f10b840..c507d0caf2 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12998,7 +12998,8 @@ mode_line_update_needed (struct window *w)
 {
   return (w->column_number_displayed != -1
          && !(PT == w->last_point && !window_outdated (w))
-         && (w->column_number_displayed != current_column ()));
+         && (!current_buffer->long_line_optimizations_p
+             && w->column_number_displayed != current_column ()));
 }
 
 /* True if window start of W is frozen and may not be changed during
@@ -20116,6 +20117,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
        || w->base_line_pos > 0
        /* Column number is displayed and different from the one displayed.  */
        || (w->column_number_displayed != -1
+          && !current_buffer->long_line_optimizations_p
           && (w->column_number_displayed != current_column ())))
       /* This means that the window has a mode line.  */
       && (window_wants_mode_line (w)
@@ -27619,7 +27621,8 @@ decode_mode_spec (struct window *w, register int c, int 
field_width,
        return "";
       else
        {
-         ptrdiff_t col = current_column ();
+         ptrdiff_t col =
+           b->long_line_optimizations_p ? 0 : current_column ();
          int disp_col = (c == 'C') ? col + 1 : col;
          w->column_number_displayed = col;
          pint2str (decode_mode_spec_buf, width, disp_col);



reply via email to

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