patch 8.2.0523: loops are repeated
Problem: Loops are repeated.
Solution: Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes #5882)
diff --git a/src/list.c b/src/list.c
index b532e28..9fe5384 100644
--- a/src/list.c
+++ b/src/list.c
@@ -20,6 +20,9 @@
// List heads for garbage collection.
static list_T *first_list = NULL; // list of all lists
+#define FOR_ALL_WATCHERS(l, lw) \
+ for ((lw) = (l)->lv_watch; (lw) != NULL; (lw) = (lw)->lw_next)
+
static void list_free_item(list_T *l, listitem_T *item);
/*
@@ -42,7 +45,7 @@
listwatch_T *lw, **lwp;
lwp = &l->lv_watch;
- for (lw = l->lv_watch; lw != NULL; lw = lw->lw_next)
+ FOR_ALL_WATCHERS(l, lw)
{
if (lw == lwrem)
{
@@ -62,7 +65,7 @@
{
listwatch_T *lw;
- for (lw = l->lv_watch; lw != NULL; lw = lw->lw_next)
+ FOR_ALL_WATCHERS(l, lw)
if (lw->lw_item == item)
lw->lw_item = item->li_next;
}