diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-06 22:13:01 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-06 22:13:01 +0200 |
commit | 00d253e2b2f435a5386582c3f857008e7ac355c2 (patch) | |
tree | 71bbea4e4c6efa593a85266e445d82377a65f454 /src/buffer.c | |
parent | ee4e0c1e9a81cb5d96e0060203a9033c2f28588e (diff) |
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/buffer.c')
-rw-r--r-- | src/buffer.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c index 8201157547..a657e72422 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -52,6 +52,9 @@ static void clear_wininfo(buf_T *buf); # define dev_T unsigned #endif +#define FOR_ALL_BUFS_FROM_LAST(buf) \ + for ((buf) = lastbuf; (buf) != NULL; (buf) = (buf)->b_prev) + #if defined(FEAT_QUICKFIX) static char *msg_loclist = N_("[Location List]"); static char *msg_qflist = N_("[Quickfix List]"); @@ -415,7 +418,7 @@ buf_valid(buf_T *buf) // Assume that we more often have a recent buffer, start with the last // one. - for (bp = lastbuf; bp != NULL; bp = bp->b_prev) + FOR_ALL_BUFS_FROM_LAST(bp) if (bp == buf) return TRUE; return FALSE; @@ -2510,7 +2513,7 @@ buflist_findname_stat( buf_T *buf; // Start at the last buffer, expect to find a match sooner. - for (buf = lastbuf; buf != NULL; buf = buf->b_prev) + FOR_ALL_BUFS_FROM_LAST(buf) if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname #ifdef UNIX , stp @@ -2593,7 +2596,7 @@ buflist_findpat( return -1; } - for (buf = lastbuf; buf != NULL; buf = buf->b_prev) + FOR_ALL_BUFS_FROM_LAST(buf) if (buf->b_p_bl == find_listed #ifdef FEAT_DIFF && (!diffmode || diff_mode_buf(buf)) |