From ea4e9b3156d4c361caa5ab816a22add3769e8ffc Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 10 Apr 2016 09:33:49 +0200 Subject: [PATCH] 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(). --- src/search.c | 5 +---- src/text.c | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/search.c b/src/search.c index 7308407e..d1ae2e00 100644 --- 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 index 2b43b798..17794cc1 100644 --- 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));