search: 10x speed improvement on large files
- do_center_window used to be very inefficient when invoked with point at a great distance from the current window. This was slowing down successful searches on large files by a factor of 10 or more.
This commit is contained in:
parent
456051b1a2
commit
4dd09ba89d
1 changed files with 8 additions and 2 deletions
10
qe.c
10
qe.c
|
|
@ -1166,8 +1166,14 @@ void do_center_cursor(EditState *s)
|
|||
if (!s->mode->text_display)
|
||||
return;
|
||||
|
||||
if (s->offset < s->offset_top) {
|
||||
int offset_top = s->offset_top;
|
||||
if (s->offset < s->offset_top
|
||||
|| (s->offset_bottom >= 0 && s->offset >= s->offset_bottom)) {
|
||||
/* if point is outside the current window, first move the
|
||||
* window to start at the line with point. This significantly
|
||||
* speeds up get_cursor_pos() on large files, except for the
|
||||
* pathological case of huge lines.
|
||||
*/
|
||||
int offset_top = s->offset;
|
||||
eb_prevc(s->b, offset_top, &offset_top);
|
||||
s->offset_top = s->mode->text_backward_offset(s, offset_top);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue