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>
diff --git a/src/mark.c b/src/mark.c
index 85f7b68..9f6a9cc 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -138,28 +138,26 @@
{
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]));
}
}