diff options
| author | Eli Zaretskii | 2022-07-23 17:43:40 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2022-07-23 17:43:40 +0300 |
| commit | fc53961c1df8bee07b6a1d461d31f449b66f1d65 (patch) | |
| tree | 09cf32b15c81c3b99b392f297d8a73680f134584 /src | |
| parent | 350e97d78e7803650c6dd2bf46fcfece8e2b4b32 (diff) | |
| download | emacs-fc53961c1df8bee07b6a1d461d31f449b66f1d65.tar.gz emacs-fc53961c1df8bee07b6a1d461d31f449b66f1d65.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/indent.c b/src/indent.c index d4ef075f001..e90e3fde203 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 | |||
| 306 | will have a variable width). | 306 | will have a variable width). |
| 307 | Ignores finite width of frame, which means that this function may return | 307 | Ignores finite width of frame, which means that this function may return |
| 308 | values greater than (frame-width). | 308 | values greater than (frame-width). |
| 309 | In a buffer with very long lines, the value can be zero, because calculating | ||
| 310 | the exact number is very expensive. | ||
| 309 | Whether the line is visible (if `selective-display' is t) has no effect; | 311 | Whether the line is visible (if `selective-display' is t) has no effect; |
| 310 | however, ^M is treated as end of line when `selective-display' is t. | 312 | however, ^M is treated as end of line when `selective-display' is t. |
| 311 | Text that has an invisible property is considered as having width 0, unless | 313 | 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 | |||
| 313 | (void) | 315 | (void) |
| 314 | { | 316 | { |
| 315 | Lisp_Object temp; | 317 | Lisp_Object temp; |
| 318 | |||
| 319 | if (current_buffer->long_line_optimizations_p) | ||
| 320 | return make_fixnum (0); | ||
| 316 | XSETFASTINT (temp, current_column ()); | 321 | XSETFASTINT (temp, current_column ()); |
| 317 | return temp; | 322 | return temp; |
| 318 | } | 323 | } |
diff --git a/src/xdisp.c b/src/xdisp.c index 690f10b8403..c507d0caf20 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -12998,7 +12998,8 @@ mode_line_update_needed (struct window *w) | |||
| 12998 | { | 12998 | { |
| 12999 | return (w->column_number_displayed != -1 | 12999 | return (w->column_number_displayed != -1 |
| 13000 | && !(PT == w->last_point && !window_outdated (w)) | 13000 | && !(PT == w->last_point && !window_outdated (w)) |
| 13001 | && (w->column_number_displayed != current_column ())); | 13001 | && (!current_buffer->long_line_optimizations_p |
| 13002 | && w->column_number_displayed != current_column ())); | ||
| 13002 | } | 13003 | } |
| 13003 | 13004 | ||
| 13004 | /* True if window start of W is frozen and may not be changed during | 13005 | /* 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) | |||
| 20116 | || w->base_line_pos > 0 | 20117 | || w->base_line_pos > 0 |
| 20117 | /* Column number is displayed and different from the one displayed. */ | 20118 | /* Column number is displayed and different from the one displayed. */ |
| 20118 | || (w->column_number_displayed != -1 | 20119 | || (w->column_number_displayed != -1 |
| 20120 | && !current_buffer->long_line_optimizations_p | ||
| 20119 | && (w->column_number_displayed != current_column ()))) | 20121 | && (w->column_number_displayed != current_column ()))) |
| 20120 | /* This means that the window has a mode line. */ | 20122 | /* This means that the window has a mode line. */ |
| 20121 | && (window_wants_mode_line (w) | 20123 | && (window_wants_mode_line (w) |
| @@ -27619,7 +27621,8 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27619 | return ""; | 27621 | return ""; |
| 27620 | else | 27622 | else |
| 27621 | { | 27623 | { |
| 27622 | ptrdiff_t col = current_column (); | 27624 | ptrdiff_t col = |
| 27625 | b->long_line_optimizations_p ? 0 : current_column (); | ||
| 27623 | int disp_col = (c == 'C') ? col + 1 : col; | 27626 | int disp_col = (c == 'C') ? col + 1 : col; |
| 27624 | w->column_number_displayed = col; | 27627 | w->column_number_displayed = col; |
| 27625 | pint2str (decode_mode_spec_buf, width, disp_col); | 27628 | pint2str (decode_mode_spec_buf, width, disp_col); |