emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/topspace 86127bf20f 160/181: Performance optimization


From: ELPA Syncer
Subject: [elpa] externals/topspace 86127bf20f 160/181: Performance optimization
Date: Tue, 23 Aug 2022 12:58:47 -0400 (EDT)

branch: externals/topspace
commit 86127bf20f241a3c421b13523f0de6590fe42055
Author: Trevor Pogue <poguete@mcmaster.ca>
Commit: Trevor Pogue <poguete@mcmaster.ca>

    Performance optimization
    
    - Improve performance of `topspace--post-command` by also only counting 
lines
      when point moved past previous line
---
 topspace.el | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/topspace.el b/topspace.el
index b1a6329372..23debe26cc 100644
--- a/topspace.el
+++ b/topspace.el
@@ -691,17 +691,24 @@ ARG defaults to 1."
 
 (defun topspace--post-command ()
   "Reduce top space height before the cursor can move past `window-end'."
-  (when (and (= topspace--pre-command-window-start 1)
-             (> (point) topspace--pre-command-point)
+  (when (= topspace--pre-command-window-start 1)
+    (let ((next-line-point))
+      (save-excursion
+        (goto-char topspace--pre-command-point)
+        (vertical-motion 1)
+        (beginning-of-visual-line)
+        (setq next-line-point (point)))
+      (when (and
+             (>= (point) next-line-point)
              (< (- (line-number-at-pos (point))
                    (line-number-at-pos topspace--pre-command-point))
                 (window-text-height)))
-    (let ((topspace-height (topspace-height)) (total-lines-past-max))
-      (when (> topspace-height 0)
-        (setq total-lines-past-max (topspace--total-lines-past-max
-                                    topspace-height))
-        (when (> total-lines-past-max 0)
-          (topspace--decrease-height total-lines-past-max)))))
+        (let ((topspace-height (topspace-height)) (total-lines-past-max))
+          (when (> topspace-height 0)
+            (setq total-lines-past-max (topspace--total-lines-past-max
+                                        topspace-height))
+            (when (> total-lines-past-max 0)
+              (topspace--decrease-height total-lines-past-max)))))))
   (when (and (= (window-start) 1)
              topspace--got-first-window-configuration-change)
     (topspace-set-height)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]