1
0
forked from aniani/vim

patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages

Problem:  :bwipe doesn't remove file from jumplist and tagstack of other
          tabpages. Time complexity of mark_forget_file() is O(n^2) when
          removing all entries (after v9.1.0554)
Solution: Use FOR_ALL_TAB_WINDOWS().  Start the loops over the arrays
          from the end instead of the start (zeertzjq)

closes: #15199

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-07-10 19:36:36 +02:00
committed by Christian Brabandt
parent a3a14d5469
commit 2e7d89b398
5 changed files with 95 additions and 12 deletions

View File

@@ -138,28 +138,26 @@ mark_forget_file(win_T *wp, int fnum)
{
int i;
for (i = 0; i < wp->w_jumplistlen; ++i)
for (i = wp->w_jumplistlen - 1; i >= 0; --i)
if (wp->w_jumplist[i].fmark.fnum == fnum)
{
vim_free(wp->w_jumplist[i].fname);
mch_memmove(&wp->w_jumplist[i], &wp->w_jumplist[i + 1],
(wp->w_jumplistlen - i - 1) * sizeof(xfmark_T));
if (wp->w_jumplistidx > i)
--wp->w_jumplistidx;
--wp->w_jumplistlen;
--i;
mch_memmove(&wp->w_jumplist[i], &wp->w_jumplist[i + 1],
(wp->w_jumplistlen - i) * sizeof(wp->w_jumplist[i]));
}
for (i = 0; i < wp->w_tagstacklen; i++)
for (i = wp->w_tagstacklen - 1; i >= 0; --i)
if (wp->w_tagstack[i].fmark.fnum == fnum)
{
tagstack_clear_entry(&wp->w_tagstack[i]);
mch_memmove(&wp->w_tagstack[i], &wp->w_tagstack[i + 1],
(wp->w_tagstacklen - i - 1) * sizeof(taggy_T));
if (wp->w_tagstackidx > i)
--wp->w_tagstackidx;
--wp->w_tagstacklen;
--i;
mch_memmove(&wp->w_tagstack[i], &wp->w_tagstack[i + 1],
(wp->w_tagstacklen - i) * sizeof(wp->w_tagstack[i]));
}
}