commit 05238f31f4d7857ef7e498b9eb77c4af2693d981
parent e21e9547420012f339292571e50e91063a39f717
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 1 May 2016 13:38:54 +0200
search: elide an unneeded function
When we're spell checking, we don't need a special mechanism to detect
we have come full circle: reaching the end-of-buffer means we're done.
So don't bother to reset came_full_circle when we're spell checking
(when begin == NULL) but simply ignore its value.
Diffstat:
3 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/src/proto.h b/src/proto.h
@@ -590,7 +590,6 @@ int findnextstr(
#endif
const filestruct *begin, size_t begin_x,
const char *needle, size_t *match_len);
-void reset_full_circle_flag(void);
void do_search(void);
#ifndef NANO_TINY
void do_findprevious(void);
diff --git a/src/search.c b/src/search.c
@@ -336,7 +336,7 @@ int findnextstr(
}
/* If we're back at the beginning, then there is no needle. */
- if (came_full_circle) {
+ if (came_full_circle && begin != NULL) {
not_found_msg(needle);
disable_nodelay();
return 0;
@@ -399,7 +399,6 @@ int findnextstr(
return 0;
}
-
disable_nodelay();
/* Set the current position to point at what we found. */
@@ -417,13 +416,6 @@ int findnextstr(
return 1;
}
-/* Clear the flag indicating that a search reached the last line of the
- * file. We need to do this just before a new search. */
-void reset_full_circle_flag(void)
-{
- came_full_circle = FALSE;
-}
-
/* Ask what to search for and then go looking for it. */
void do_search(void)
{
@@ -505,7 +497,7 @@ void go_looking(void)
size_t was_current_x = openfile->current_x;
int didfind;
- reset_full_circle_flag();
+ came_full_circle = FALSE;
didfind = findnextstr(
#ifndef DISABLE_SPELLER
@@ -653,7 +645,7 @@ ssize_t do_replace_loop(
}
#endif /* !NANO_TINY */
- reset_full_circle_flag();
+ came_full_circle = FALSE;
while (TRUE) {
int i = 0;
diff --git a/src/text.c b/src/text.c
@@ -2417,10 +2417,8 @@ bool do_int_spell_fix(const char *word)
openfile->current = openfile->fileage;
openfile->current_x = (size_t)-1;
- reset_full_circle_flag();
-
/* Find the first whole occurrence of word. */
- result = findnextstr(TRUE, openfile->fileage, 0, word, NULL);
+ result = findnextstr(TRUE, NULL, 0, word, NULL);
/* The word must exist; if not, something is wrong. */
if (result == 0)