From 6eca958b2e72b7a264e86ec35cd5119d975ee251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 13 Apr 2016 17:37:29 +0200 Subject: vis: stop repeated motions as soon as resulting position remains the same This improves responsiveness of {count}j for files with less than count lines. For huge files this will still be slow because the code tries to restore cursor position on every line before moving on to the next. Also moving up will generally be slower than downwards. Use {count}% (fastest) or or :count (slower) instead. Close #267 --- vis.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vis.c b/vis.c index 730763b..4926555 100644 --- a/vis.c +++ b/vis.c @@ -495,6 +495,7 @@ void action_do(Vis *vis, Action *a) { if (a->movement) { size_t start = pos; for (int i = 0; i < count; i++) { + size_t pos_prev = pos; if (a->movement->txt) pos = a->movement->txt(txt, pos); else if (a->movement->cur) @@ -509,7 +510,7 @@ void action_do(Vis *vis, Action *a) { pos = a->movement->win(vis, win, pos); else if (a->movement->user) pos = a->movement->user(vis, win, a->movement->data, pos); - if (pos == EPOS || a->movement->type & IDEMPOTENT) + if (pos == EPOS || a->movement->type & IDEMPOTENT || pos == pos_prev) break; } -- cgit v1.2.3