nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 482fb352b8d203d48508c1b1b7d455adb007f8b0
parent 8766e7bdcb9c9768a4c127c3cd76e3bb6d8be8cb
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 27 Jun 2017 13:47:26 +0200

tweaks: elide unneeded calls of get_last_chunk_leftedge()

And then elide the function entirely as it's called just once.

Diffstat:
Msrc/proto.h | 1-
Msrc/winio.c | 21++++++---------------
2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/proto.h b/src/proto.h @@ -670,7 +670,6 @@ size_t get_chunk(filestruct *line, size_t column, size_t *leftedge); size_t get_chunk_row(filestruct *line, size_t column); size_t get_chunk_leftedge(filestruct *line, size_t column); size_t get_last_chunk_row(filestruct *line); -size_t get_last_chunk_leftedge(filestruct *line); void ensure_firstcolumn_is_aligned(void); #endif void edit_redraw(filestruct *old_current); diff --git a/src/winio.c b/src/winio.c @@ -2834,7 +2834,7 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge) break; *line = (*line)->prev; - current_leftedge = get_last_chunk_leftedge(*line); + current_leftedge = get_chunk_leftedge(*line, (size_t)-1); } /* Only change leftedge when we actually could move. */ @@ -2863,24 +2863,22 @@ int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge) #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { size_t current_leftedge = *leftedge; - size_t last_leftedge = get_last_chunk_leftedge(*line); /* Advance through the requested number of chunks. */ for (i = nrows; i > 0; i--) { - if (current_leftedge < last_leftedge) { - bool dummy; + bool end_of_line = FALSE; - current_leftedge = get_softwrap_breakpoint((*line)->data, - current_leftedge, &dummy); + current_leftedge = get_softwrap_breakpoint((*line)->data, + current_leftedge, &end_of_line); + + if (!end_of_line) continue; - } if (*line == openfile->filebot) break; *line = (*line)->next; current_leftedge = 0; - last_leftedge = get_last_chunk_leftedge(*line); } /* Only change leftedge when we actually could move. */ @@ -3130,13 +3128,6 @@ size_t get_last_chunk_row(filestruct *line) return get_chunk_row(line, (size_t)-1); } -/* Return the leftmost column of the last softwrapped chunk of the given - * line. */ -size_t get_last_chunk_leftedge(filestruct *line) -{ - return get_chunk_leftedge(line, (size_t)-1); -} - /* Ensure that firstcolumn is at the starting column of the softwrapped chunk * it's on. We need to do this when the number of columns of the edit window * has changed, because then the width of softwrapped chunks has changed. */