commit d1e28417d5dea8141f161feac6a0a07fc6a3fcca
parent 9410a55679df16420de1a9e5867791f0525a9ed5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 24 Aug 2022 16:07:45 +0200
tweaks: move to a given line number more efficiently
Instead of starting always from the top of the buffer, start at the
current line, as it is quite likely to be near the target line.
(Since the previous commit we're assuming that openfile->current is
always valid, so we might as well make use of this assumption.)
Also, rename a parameter to make its meaning more explicit.
Diffstat:
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/search.c b/src/search.c
@@ -737,18 +737,15 @@ void ask_for_and_do_replacements(void)
}
/* Go to the specified line and x position. */
-void goto_line_posx(ssize_t line, size_t pos_x)
+void goto_line_posx(ssize_t linenumber, size_t pos_x)
{
#ifdef ENABLE_COLOR
- if (line > openfile->edittop->lineno + editwinrows ||
- (ISSET(SOFTWRAP) && line > openfile->current->lineno))
+ if (linenumber > openfile->edittop->lineno + editwinrows ||
+ (ISSET(SOFTWRAP) && linenumber > openfile->current->lineno))
recook |= perturbed;
#endif
- for (openfile->current = openfile->filetop; line > 1 &&
- openfile->current != openfile->filebot; line--)
- openfile->current = openfile->current->next;
-
+ openfile->current = line_from_number(linenumber);
openfile->current_x = pos_x;
openfile->placewewant = xplustabs();