diff options
| author | Eli Zaretskii | 2017-07-09 17:37:23 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-09 17:37:23 +0300 |
| commit | 83218cf4c34c3593b4d58bd68d1f280cb3e6634b (patch) | |
| tree | bd380cdba83ecd2995dfcd1fc9ea80b2db21c522 /src | |
| parent | b2aef8122ad1404854728615ca03a7f3cd3f93a3 (diff) | |
| download | emacs-83218cf4c34c3593b4d58bd68d1f280cb3e6634b.tar.gz emacs-83218cf4c34c3593b4d58bd68d1f280cb3e6634b.zip | |
Speed up display of line numbers for very large buffers
* src/xdisp.c (maybe_produce_line_number): Speed up line counting
using values cached by mode-line display of line numbers.
(Bug#27622)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 5df2dd18311..28ed7685236 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -20823,7 +20823,6 @@ maybe_produce_line_number (struct it *it) | |||
| 20823 | ptrdiff_t start_from, bytepos; | 20823 | ptrdiff_t start_from, bytepos; |
| 20824 | ptrdiff_t this_line; | 20824 | ptrdiff_t this_line; |
| 20825 | bool first_time = false; | 20825 | bool first_time = false; |
| 20826 | ptrdiff_t beg = display_line_numbers_widen ? BEG : BEGV; | ||
| 20827 | ptrdiff_t beg_byte = display_line_numbers_widen ? BEG_BYTE : BEGV_BYTE; | 20826 | ptrdiff_t beg_byte = display_line_numbers_widen ? BEG_BYTE : BEGV_BYTE; |
| 20828 | ptrdiff_t z_byte = display_line_numbers_widen ? Z_BYTE : ZV_BYTE; | 20827 | ptrdiff_t z_byte = display_line_numbers_widen ? Z_BYTE : ZV_BYTE; |
| 20829 | void *itdata = bidi_shelve_cache (); | 20828 | void *itdata = bidi_shelve_cache (); |
| @@ -20834,8 +20833,21 @@ maybe_produce_line_number (struct it *it) | |||
| 20834 | { | 20833 | { |
| 20835 | if (!last_line) | 20834 | if (!last_line) |
| 20836 | { | 20835 | { |
| 20837 | /* FIXME: Maybe reuse the data in it->w->base_line_number. */ | 20836 | /* If possible, reuse data cached by line-number-mode. */ |
| 20838 | start_from = beg; | 20837 | if (it->w->base_line_number > 0 |
| 20838 | && it->w->base_line_pos > 0 | ||
| 20839 | && it->w->base_line_pos <= IT_CHARPOS (*it) | ||
| 20840 | /* line-number-mode always displays narrowed line | ||
| 20841 | numbers, so we cannot use its data if the user wants | ||
| 20842 | line numbers that disregard narrowing. */ | ||
| 20843 | && !(display_line_numbers_widen | ||
| 20844 | && (BEG_BYTE != BEGV_BYTE || Z_BYTE != ZV_BYTE))) | ||
| 20845 | { | ||
| 20846 | start_from = CHAR_TO_BYTE (it->w->base_line_pos); | ||
| 20847 | last_line = it->w->base_line_number - 1; | ||
| 20848 | } | ||
| 20849 | else | ||
| 20850 | start_from = beg_byte; | ||
| 20839 | if (!it->lnum_bytepos) | 20851 | if (!it->lnum_bytepos) |
| 20840 | first_time = true; | 20852 | first_time = true; |
| 20841 | } | 20853 | } |
| @@ -20845,7 +20857,7 @@ maybe_produce_line_number (struct it *it) | |||
| 20845 | /* Paranoia: what if someone changes the narrowing since the | 20857 | /* Paranoia: what if someone changes the narrowing since the |
| 20846 | last time display_line was called? Shouldn't really happen, | 20858 | last time display_line was called? Shouldn't really happen, |
| 20847 | but who knows what some crazy Lisp invoked by :eval could do? */ | 20859 | but who knows what some crazy Lisp invoked by :eval could do? */ |
| 20848 | if (!(beg_byte <= start_from && start_from < z_byte)) | 20860 | if (!(beg_byte <= start_from && start_from <= z_byte)) |
| 20849 | { | 20861 | { |
| 20850 | last_line = 0; | 20862 | last_line = 0; |
| 20851 | start_from = beg_byte; | 20863 | start_from = beg_byte; |