Mercurial > vim
diff src/list.c @ 19888:435726a03481 v8.2.0500
patch 8.2.0500: using the same loop in many places
Commit: https://github.com/vim/vim/commit/aeea72151c31d686bcbb7b06d895006d7363585c
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 2 18:50:46 2020 +0200
patch 8.2.0500: using the same loop in many places
Problem: Using the same loop in many places.
Solution: Define more FOR_ALL macros. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5339)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 02 Apr 2020 19:00:05 +0200 |
parents | 293a22b677a8 |
children | dcec86d796bc |
line wrap: on
line diff
--- a/src/list.c +++ b/src/list.c @@ -1109,7 +1109,7 @@ write_list(FILE *fd, list_T *list, int b char_u *s; range_list_materialize(list); - for (li = list->lv_first; li != NULL; li = li->li_next) + FOR_ALL_LIST_ITEMS(list, li) { for (s = tv_get_string(&li->li_tv); *s != NUL; ++s) { @@ -1207,7 +1207,7 @@ f_list2str(typval_T *argvars, typval_T * else char2bytes = mb_char2bytes; - for (li = l->lv_first; li != NULL; li = li->li_next) + FOR_ALL_LIST_ITEMS(l, li) { buf[(*char2bytes)(tv_get_number(&li->li_tv), buf)] = NUL; ga_concat(&ga, buf); @@ -1216,7 +1216,7 @@ f_list2str(typval_T *argvars, typval_T * } else if (ga_grow(&ga, list_len(l) + 1) == OK) { - for (li = l->lv_first; li != NULL; li = li->li_next) + FOR_ALL_LIST_ITEMS(l, li) ga_append(&ga, tv_get_number(&li->li_tv)); ga_append(&ga, NUL); } @@ -1579,7 +1579,7 @@ do_sort_uniq(typval_T *argvars, typval_T if (sort) { // sort(): ptrs will be the list to sort - for (li = l->lv_first; li != NULL; li = li->li_next) + FOR_ALL_LIST_ITEMS(l, li) { ptrs[i].item = li; ptrs[i].idx = i;