summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-06 22:13:01 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-06 22:13:01 +0200
commit00d253e2b2f435a5386582c3f857008e7ac355c2 (patch)
tree71bbea4e4c6efa593a85266e445d82377a65f454 /src/list.c
parentee4e0c1e9a81cb5d96e0060203a9033c2f28588e (diff)
downloadvim-git-00d253e2b2f435a5386582c3f857008e7ac355c2.tar.gz
patch 8.2.0523: loops are repeatedv8.2.0523
Problem: Loops are repeated. Solution: Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes #5882)
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index b532e28eb..9fe538414 100644
--- a/src/list.c
+++ b/src/list.c
@@ -20,6 +20,9 @@ static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob");
// 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 @@ list_rem_watch(list_T *l, listwatch_T *lwrem)
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 @@ list_fix_watch(list_T *l, listitem_T *item)
{
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;
}