refactor(wininfo): change wininfo from a linked list to an array

"wininfo" is going to be my next victim. The main problem with wininfo
is that it is "all or nothing", i e either all state about a buffer in a
window is considered valid or none of it is. This needs to be fixed to
address some long running grievances.

For now this is just a warmup: refactor it from a linked list to a
vector.
This commit is contained in:
bfredl
2024-12-10 14:03:44 +01:00
parent 9c6a3703bb
commit 2d6f57b289
8 changed files with 67 additions and 86 deletions

View File

@@ -2402,14 +2402,15 @@ static void f_getchangelist(typval_T *argvars, typval_T *rettv, EvalFuncData fpt
if (buf == curwin->w_buffer) {
changelistindex = curwin->w_changelistidx;
} else {
wininfo_T *wip;
changelistindex = buf->b_changelistlen;
FOR_ALL_BUF_WININFO(buf, wip) {
for (size_t i = 0; i < kv_size(buf->b_wininfo); i++) {
WinInfo *wip = kv_A(buf->b_wininfo, i);
if (wip->wi_win == curwin) {
changelistindex = wip->wi_changelistidx;
break;
}
}
changelistindex = wip != NULL ? wip->wi_changelistidx : buf->b_changelistlen;
}
tv_list_append_number(rettv->vval.v_list, (varnumber_T)changelistindex);