diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-02 18:50:46 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-02 18:50:46 +0200 |
commit | aeea72151c31d686bcbb7b06d895006d7363585c (patch) | |
tree | 500d487503a1a82cecc8f2a3e9bf89b50638fe5a /src/diff.c | |
parent | f10806b25090879fdc1a86cc0da2f4f34fd21921 (diff) | |
download | vim-git-aeea72151c31d686bcbb7b06d895006d7363585c.tar.gz |
patch 8.2.0500: using the same loop in many placesv8.2.0500
Problem: Using the same loop in many places.
Solution: Define more FOR_ALL macros. (Yegappan Lakshmanan, closes #5339)
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/diff.c b/src/diff.c index f99690454..3d61d49d1 100644 --- a/src/diff.c +++ b/src/diff.c @@ -90,6 +90,9 @@ static int parse_diff_ed(char_u *line, linenr_T *lnum_orig, long *count_orig, li static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new, long *count_new); static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf); +#define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \ + for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next) + /* * Called when deleting or unloading a buffer: No longer make a diff with it. */ @@ -1857,7 +1860,7 @@ diff_check(win_T *wp, linenr_T lnum) #endif // search for a change that includes "lnum" in the list of diffblocks. - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) + FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; if (dp == NULL || lnum < dp->df_lnum[idx]) @@ -2069,7 +2072,7 @@ diff_set_topline(win_T *fromwin, win_T *towin) towin->w_topfill = 0; // search for a change that includes "lnum" in the list of diffblocks. - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) + FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx]) break; if (dp == NULL) @@ -2374,7 +2377,7 @@ diff_find_change( } // search for a change that includes "lnum" in the list of diffblocks. - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) + FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; if (dp == NULL || diff_check_sanity(curtab, dp) == FAIL) @@ -2508,7 +2511,7 @@ diff_infold(win_T *wp, linenr_T lnum) if (curtab->tp_first_diff == NULL) return TRUE; - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) + FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) { // If this change is below the line there can't be any further match. if (dp->df_lnum[idx] - diff_context > lnum) @@ -3001,7 +3004,7 @@ diff_get_corresponding_line_int( if (curtab->tp_first_diff == NULL) // no diffs today return lnum1; - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) + FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) { if (dp->df_lnum[idx1] > lnum1) return lnum1 - baseline; @@ -3070,7 +3073,7 @@ diff_lnum_win(linenr_T lnum, win_T *wp) ex_diffupdate(NULL); // update after a big change // search for a change that includes "lnum" in the list of diffblocks. - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) + FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; |