tweaks: add a condition, so that two ifs can be elided

Now all functions that are relevant only to softwrapping
get called only when softwrapping is on.

This also allows to elide an intermediate function call.
master
Benno Schulenberg 2020-05-13 12:29:44 +02:00
parent e8e9b8ad82
commit 78bfc9223a
2 changed files with 7 additions and 13 deletions

View File

@ -556,8 +556,8 @@ void do_scroll_down(void)
if (editwinrows > 1 && (openfile->edittop->next != NULL
#ifndef NANO_TINY
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
number_of_chunks_in(openfile->edittop)
|| (ISSET(SOFTWRAP) && (number_of_chunks_in(openfile->edittop) >
chunk_for(openfile->firstcolumn, openfile->edittop)))
#endif
))
edit_scroll(FORWARD);

View File

@ -3098,31 +3098,25 @@ size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge)
* relative to the first row (zero-based). */
size_t chunk_for(size_t column, linestruct *line)
{
if (ISSET(SOFTWRAP))
return get_chunk_and_edge(column, line, NULL);
else
return 0;
return get_chunk_and_edge(column, line, NULL);
}
/* Return the leftmost column of the softwrapped chunk of the given line that
* column is on. */
size_t leftedge_for(size_t column, linestruct *line)
{
if (ISSET(SOFTWRAP)) {
size_t leftedge;
size_t leftedge;
get_chunk_and_edge(column, line, &leftedge);
get_chunk_and_edge(column, line, &leftedge);
return leftedge;
} else
return 0;
return leftedge;
}
/* Return the row of the last softwrapped chunk of the given line, relative to
* the first row (zero-based). */
size_t number_of_chunks_in(linestruct *line)
{
return chunk_for((size_t)-1, line);
return get_chunk_and_edge((size_t)-1, line, NULL);
}
/* Ensure that firstcolumn is at the starting column of the softwrapped chunk