mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 #5339)
This commit is contained in:
15
src/diff.c
15
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;
|
||||
|
||||
|
Reference in New Issue
Block a user