patch 9.1.1385: inefficient loop for 'nosmoothscroll' scrolling

Problem:  Loop that ensures "w_skipcol" is zero with 'nosmoothscroll'
	  for (half)-page scrolling is inefficient.
Solution: Calculate the required "count" instead of looping until
	  "w_skipcol" is zero (Luuk van Baal).

fixes: #17301
closes: #17306

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/move.c b/src/move.c
index f4bce40..1c1edde 100644
--- a/src/move.c
+++ b/src/move.c
@@ -3212,12 +3212,15 @@
 	// extra for scrolling backward so that consuming skipcol is symmetric.
 	if (labs(curwin->w_topline - prev_topline) > (dir == BACKWARD))
 	    fixdir = dir * -1;
-	while (curwin->w_skipcol > 0
-	    && curwin->w_topline < curbuf->b_ml.ml_line_count)
-	{
-	    scroll_redraw(fixdir == FORWARD, 1);
-	    *curscount += (fixdir == dir ? 1 : -1);
-	}
+
+	int width1 = curwin->w_width - curwin_col_off();
+	int width2 = width1 + curwin_col_off2();
+	count = 1 + (curwin->w_skipcol - width1) / width2;
+	if (fixdir == FORWARD)
+	    count = 2 + (linetabsize_eol(curwin, curwin->w_topline)
+					- curwin->w_skipcol - width1) / width2;
+	scroll_redraw(fixdir == FORWARD, count);
+	*curscount += count * (fixdir == dir ? 1 : -1);
     }
     curwin->w_p_sms = prev_sms;