From 6fc70cc474ffc6035071d958077e60abd6fd8e2f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 23 Mar 2016 19:48:44 +0000 Subject: [PATCH] Removing a pointless condition, and making use of an existing intermediary variable for a little optimization. Openfile can never be NULL -- it should have been called openbuffer, and before we start fiddling with the cursor, we will always have an open buffer. Edittop might be NULL, but that's okay. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5763 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/winio.c | 12 ++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 231cbe4b..bc01ede1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ that was meant to do this. This fixes Savannah bug #47188. * src/search.c (findnextstr): Clean up and rename a variable. * src/search.c (findnextstr): Poll the keyboard once per second. + * src/winio.c (reset_cursor): Remove a pointless condition, and make + use of an existing intermediary variable. 2016-03-22 Thomas Rosenau * configure.ac, src/*.c: Check for the existence of the REG_ENHANCED diff --git a/src/winio.c b/src/winio.c index e8699445..c18ac537 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2274,15 +2274,7 @@ void onekey(const char *keystroke, const char *desc, size_t len) * in the edit window at (current_y, current_x). */ void reset_cursor(void) { - size_t xpt; - /* If we haven't opened any files yet, put the cursor in the top - * left corner of the edit window and get out. */ - if (openfile == NULL) { - wmove(edit, 0, 0); - return; - } - - xpt = xplustabs(); + size_t xpt = xplustabs(); #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { @@ -2292,7 +2284,7 @@ void reset_cursor(void) for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next) openfile->current_y += (strlenpt(tmp->data) / COLS) + 1; - openfile->current_y += xplustabs() / COLS; + openfile->current_y += xpt / COLS; if (openfile->current_y < editwinrows) wmove(edit, openfile->current_y, xpt % COLS); } else -- 2.39.5