diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-23 19:32:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-23 19:32:27 +0800 |
commit | 3b7548504344d72b0228e1bd29a7f28df813a3bd (patch) | |
tree | 59ff43ee4670fc273c9eed78b6a7a45c60932ef4 /src | |
parent | 0371d0f7afa5e01dd2ac8bbd3abcf0f7454872b3 (diff) | |
download | rneovim-3b7548504344d72b0228e1bd29a7f28df813a3bd.tar.gz rneovim-3b7548504344d72b0228e1bd29a7f28df813a3bd.tar.bz2 rneovim-3b7548504344d72b0228e1bd29a7f28df813a3bd.zip |
revert: "shada/context: fully remove jumplist duplicates #10898" (#21874)
This reverts commit 8b8ecf44f2cda43bbd710ec22ef99439b71888cd.
It is causing performance problems on exit.
Fix #21082.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mark.c | 25 | ||||
-rw-r--r-- | src/nvim/shada.c | 11 |
2 files changed, 17 insertions, 19 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index a76472230d..f1a1f25e6c 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1380,18 +1380,21 @@ void mark_col_adjust(linenr_T lnum, colnr_T mincol, linenr_T lnum_amount, long c // When deleting lines, this may create duplicate marks in the // jumplist. They will be removed here for the specified window. -// When "checktail" is true, removes tail jump if it matches current position. -void cleanup_jumplist(win_T *wp, bool checktail) +// When "loadfiles" is true first ensure entries have the "fnum" field set +// (this may be a bit slow). +void cleanup_jumplist(win_T *wp, bool loadfiles) { int i; - // Load all the files from the jump list. This is - // needed to properly clean up duplicate entries, but will take some - // time. - for (i = 0; i < wp->w_jumplistlen; i++) { - if ((wp->w_jumplist[i].fmark.fnum == 0) - && (wp->w_jumplist[i].fmark.mark.lnum != 0)) { - fname2fnum(&wp->w_jumplist[i]); + if (loadfiles) { + // If specified, load all the files from the jump list. This is + // needed to properly clean up duplicate entries, but will take some + // time. + for (i = 0; i < wp->w_jumplistlen; i++) { + if ((wp->w_jumplist[i].fmark.fnum == 0) + && (wp->w_jumplist[i].fmark.mark.lnum != 0)) { + fname2fnum(&wp->w_jumplist[i]); + } } } @@ -1439,8 +1442,8 @@ void cleanup_jumplist(win_T *wp, bool checktail) // When pointer is below last jump, remove the jump if it matches the current // line. This avoids useless/phantom jumps. #9805 - if (checktail && wp->w_jumplistlen - && wp->w_jumplistidx == wp->w_jumplistlen) { + if (loadfiles // otherwise (i.e.: Shada), last entry should be kept + && wp->w_jumplistlen && wp->w_jumplistidx == wp->w_jumplistlen) { const xfmark_T *fm_last = &wp->w_jumplist[wp->w_jumplistlen - 1]; if (fm_last->fmark.fnum == curbuf->b_fnum && fm_last->fmark.mark.lnum == wp->w_cursor.lnum) { diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 95151936c1..90a01aaf97 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2667,8 +2667,6 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef } // Initialize jump list - setpcmark(); - cleanup_jumplist(curwin, false); wms->jumps_size = shada_init_jumps(wms->jumps, &removable_bufs); const bool search_highlighted = !(no_hlsearch @@ -4038,13 +4036,11 @@ static bool shada_removable(const char *name) static inline size_t shada_init_jumps(PossiblyFreedShadaEntry *jumps, khash_t(bufset) *const removable_bufs) { - if (!curwin->w_jumplistlen) { - return 0; - } - + // Initialize jump list size_t jumps_size = 0; const void *jump_iter = NULL; - + setpcmark(); + cleanup_jumplist(curwin, false); do { xfmark_T fm; jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm); @@ -4117,7 +4113,6 @@ void shada_encode_jumps(msgpack_sbuffer *const sbuf) khash_t(bufset) removable_bufs = KHASH_EMPTY_TABLE(bufset); find_removable_bufs(&removable_bufs); PossiblyFreedShadaEntry jumps[JUMPLISTSIZE]; - cleanup_jumplist(curwin, true); size_t jumps_size = shada_init_jumps(jumps, &removable_bufs); msgpack_packer packer; msgpack_packer_init(&packer, sbuf, msgpack_sbuffer_write); |