From 541f61b378eca85fa118caff5ad97b56171baa98 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 1 Dec 2021 11:22:58 +0800 Subject: [PATCH] Avoid unnecessary call when pixel scrolling * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-down): Avoid unnecessary call to `posn-at-point' --- lisp/pixel-scroll.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index f514a010ad0..65671534865 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -388,13 +388,14 @@ the height of the current window." (point)))) (if (and (< (point) next-pos) (let ((pos-visibility (pos-visible-in-window-p next-pos nil t))) - (or (eq (length pos-visibility) 2) - (when-let* ((posn (posn-at-point next-pos)) - (edges (window-edges nil t)) - (usable-height (- (nth 3 edges) - (nth 1 edges)))) - (> (cdr (posn-object-width-height posn)) - usable-height))))) + (and pos-visibility + (or (eq (length pos-visibility) 2) + (when-let* ((posn (posn-at-point next-pos)) + (edges (window-edges nil t)) + (usable-height (- (nth 3 edges) + (nth 1 edges)))) + (> (cdr (posn-object-width-height posn)) + usable-height)))))) (goto-char next-pos)) (if (or (consp object) (stringp object)) ;; We are either on an overlay or a string, so set vscroll -- 2.39.5