mirror of
git://git.sv.gnu.org/nano.git
synced 2025-03-19 16:03:08 +03:00
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.
This commit is contained in:
parent
e8e9b8ad82
commit
78bfc9223a
@ -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);
|
||||
|
16
src/winio.c
16
src/winio.c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user