nano

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

commit ea4e9b3156d4c361caa5ab816a22add3769e8ffc
parent 7ba356a62c0ee345be8a427e7579d0d10250b602
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sun, 10 Apr 2016 09:33:49 +0200

search: don't set placewewant when we are just iterating

In the innermost search loop, don't set placewewant, because this loop
is also used for replacing and spell fixing, when we don't really want
to be there: we are just passing through.  Not setting placewewant means
we don't need to save and restore it in those passing-through routines.

The value of placewewant is only relevant when doing cursor movement,
which doesn't happen during replacing nor spell checking, so there is
no need to keep placewewant up to date -- it is set when it matters:
at the end of go_looking().

Diffstat:
Msrc/search.c | 5+----
Msrc/text.c | 3---
2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/search.c b/src/search.c @@ -384,7 +384,6 @@ int findnextstr( /* Set the current position to point at what we found. */ openfile->current = fileptr; openfile->current_x = found - fileptr->data; - openfile->placewewant = xplustabs(); openfile->current_y = fileptr->lineno - openfile->edittop->lineno; /* When requested, pass back the length of the match. */ @@ -797,7 +796,7 @@ ssize_t do_replace_loop( void do_replace(void) { filestruct *edittop_save, *begin; - size_t begin_x, pww_save; + size_t begin_x; ssize_t numreplaced; int i; @@ -848,7 +847,6 @@ void do_replace(void) edittop_save = openfile->edittop; begin = openfile->current; begin_x = openfile->current_x; - pww_save = openfile->placewewant; numreplaced = do_replace_loop( #ifndef DISABLE_SPELLER @@ -860,7 +858,6 @@ void do_replace(void) openfile->edittop = edittop_save; openfile->current = begin; openfile->current_x = begin_x; - openfile->placewewant = pww_save; edit_refresh(); diff --git a/src/text.c b/src/text.c @@ -2354,7 +2354,6 @@ bool do_int_spell_fix(const char *word) { char *save_search, *exp_word; size_t current_x_save = openfile->current_x; - size_t pww_save = openfile->placewewant; filestruct *edittop_save = openfile->edittop; filestruct *current_save = openfile->current; /* Save where we are. */ @@ -2416,7 +2415,6 @@ bool do_int_spell_fix(const char *word) openfile->edittop = openfile->fileage; openfile->current = openfile->fileage; openfile->current_x = (size_t)-1; - openfile->placewewant = 0; findnextstr_wrap_reset(); @@ -2490,7 +2488,6 @@ bool do_int_spell_fix(const char *word) openfile->edittop = edittop_save; openfile->current = current_save; openfile->current_x = current_x_save; - openfile->placewewant = pww_save; /* Restore the settings of the global flags. */ memcpy(flags, stash, sizeof(flags));