From 08e5eea5b618f4fe7d3dd973f232f3adf858291e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 27 Oct 2015 16:57:32 +0000 Subject: [PATCH] Not calculating the line length twice. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5374 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/move.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a92ddb0c..9c19c975 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2015-10-27 Benno Schulenberg * src/move.c (do_next_word): Rewrite this function to use the same logic as do_prev_word(), reducing its number of lines to half. + * src/move.c (do_down): Don't calculate the line length twice. And + in the bargain avoid a warning about comparison of signed/unsigned. 2015-09-05 Benno Schulenberg * src/winio.c (display_string, edit_draw): Force a redraw of a line diff --git a/src/move.c b/src/move.c index f8d53405..9735bf53 100644 --- a/src/move.c +++ b/src/move.c @@ -478,11 +478,11 @@ void do_down( topline = openfile->edittop; /* Reduce the amount when there are overlong lines at the top. */ for (enough = 1; enough < amount; enough++) { - if (amount <= strlenpt(topline->data) / COLS) { + amount -= strlenpt(topline->data) / COLS; + if (amount <= 0) { amount = enough; break; } - amount -= strlenpt(topline->data) / COLS; topline = topline->next; } } -- 2.39.5