fold: add const to hasFoldingWin() variables

cache is bool so update callers to pass true/false, not TRUE/FALSE.
This commit is contained in:
Jan Edmund Lazo 2018-08-02 08:31:04 -04:00
parent d2c1d9c466
commit 3de785e7b5
3 changed files with 37 additions and 34 deletions

View File

@ -1486,7 +1486,7 @@ int diff_check(win_T *wp, linenr_T lnum)
}
// A closed fold never has filler lines.
if (hasFoldingWin(wp, lnum, NULL, NULL, TRUE, NULL)) {
if (hasFoldingWin(wp, lnum, NULL, NULL, true, NULL)) {
return 0;
}
@ -1793,7 +1793,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin)
check_topfill(towin, false);
(void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
NULL, TRUE, NULL);
NULL, true, NULL);
}
/// This is called when 'diffopt' is changed.

View File

@ -147,29 +147,27 @@ int hasAnyFolding(win_T *win)
*/
bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
{
return hasFoldingWin(curwin, lnum, firstp, lastp, TRUE, NULL);
return hasFoldingWin(curwin, lnum, firstp, lastp, true, NULL);
}
/* hasFoldingWin() {{{2 */
bool hasFoldingWin(
win_T *win,
linenr_T lnum,
linenr_T *firstp,
linenr_T *lastp,
int cache, /* when TRUE: use cached values of window */
foldinfo_T *infop /* where to store fold info */
win_T *const win,
const linenr_T lnum,
linenr_T *const firstp,
linenr_T *const lastp,
const bool cache, // when true: use cached values of window
foldinfo_T *const infop // where to store fold info
)
{
bool had_folded = false;
linenr_T first = 0;
linenr_T last = 0;
linenr_T lnum_rel = lnum;
int x;
fold_T *fp;
int level = 0;
bool use_level = false;
bool maybe_small = false;
garray_T *gap;
int low_level = 0;
checkupdate(win);
@ -187,7 +185,7 @@ bool hasFoldingWin(
* First look in cached info for displayed lines. This is probably
* the fastest, but it can only be used if the entry is still valid.
*/
x = find_wl_entry(win, lnum);
const int x = find_wl_entry(win, lnum);
if (x >= 0) {
first = win->w_lines[x].wl_lnum;
last = win->w_lines[x].wl_lastlnum;
@ -199,7 +197,7 @@ bool hasFoldingWin(
/*
* Recursively search for a fold that contains "lnum".
*/
gap = &win->w_folds;
garray_T *gap = &win->w_folds;
for (;; ) {
if (!foldFind(gap, lnum_rel, &fp))
break;
@ -296,8 +294,9 @@ long foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop)
{
linenr_T last;
if (hasFoldingWin(win, lnum, NULL, &last, FALSE, infop))
if (hasFoldingWin(win, lnum, NULL, &last, false, infop)) {
return (long)(last - lnum + 1);
}
return 0;
}

View File

@ -783,16 +783,18 @@ static void win_update(win_T *wp)
}
}
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL);
if (mod_top > lnumt)
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL);
if (mod_top > lnumt) {
mod_top = lnumt;
}
/* Now do the same for the bottom line (one above mod_bot). */
--mod_bot;
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL);
++mod_bot;
if (mod_bot < lnumb)
// Now do the same for the bottom line (one above mod_bot).
mod_bot--;
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, true, NULL);
mod_bot++;
if (mod_bot < lnumb) {
mod_bot = lnumb;
}
}
/* When a change starts above w_topline and the end is below
@ -876,7 +878,7 @@ static void win_update(win_T *wp)
++j;
if (j >= wp->w_height - 2)
break;
(void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL);
(void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
}
} else
j = wp->w_lines[0].wl_lnum - wp->w_topline;
@ -1307,15 +1309,15 @@ static void win_update(win_T *wp)
/* Able to count old number of rows: Count new window
* rows, and may insert/delete lines */
j = idx;
for (l = lnum; l < mod_bot; ++l) {
if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
++new_rows;
else if (l == wp->w_topline)
new_rows += plines_win_nofill(wp, l, TRUE)
+ wp->w_topfill;
else
new_rows += plines_win(wp, l, TRUE);
++j;
for (l = lnum; l < mod_bot; l++) {
if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) {
new_rows++;
} else if (l == wp->w_topline) {
new_rows += plines_win_nofill(wp, l, true) + wp->w_topfill;
} else {
new_rows += plines_win(wp, l, true);
}
j++;
if (new_rows > wp->w_height - row - 2) {
/* it's getting too much, must redraw the rest */
new_rows = 9999;
@ -5525,10 +5527,12 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
&& re_multiline(shl->rm.regprog)) {
if (shl->first_lnum == 0) {
for (shl->first_lnum = lnum;
shl->first_lnum > wp->w_topline; --shl->first_lnum)
if (hasFoldingWin(wp, shl->first_lnum - 1,
NULL, NULL, TRUE, NULL))
shl->first_lnum > wp->w_topline;
shl->first_lnum--) {
if (hasFoldingWin(wp, shl->first_lnum - 1, NULL, NULL, true, NULL)) {
break;
}
}
}
if (cur != NULL) {
cur->pos.cur = 0;