From 482fb352b8d203d48508c1b1b7d455adb007f8b0 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@telfort.nl> Date: Tue, 27 Jun 2017 13:47:26 +0200 Subject: [PATCH] tweaks: elide unneeded calls of get_last_chunk_leftedge() And then elide the function entirely as it's called just once. --- src/proto.h | 1 - src/winio.c | 21 ++++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/proto.h b/src/proto.h index 605f2cde..b97487ce 100644 --- 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 index 7071d670..bb47eb64 100644 --- 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. */ -- GitLab