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

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

[elpa] scratch/add-vdiff 4596948 081/258: Reduce load in vdiff--scroll-f


From: Justin Burkett
Subject: [elpa] scratch/add-vdiff 4596948 081/258: Reduce load in vdiff--scroll-function
Date: Wed, 17 May 2017 08:13:27 -0400 (EDT)

branch: scratch/add-vdiff
commit 45969485d67ecd5e6f5ad98e4c8a72a834378416
Author: justbur <address@hidden>
Commit: justbur <address@hidden>

    Reduce load in vdiff--scroll-function
    
    Calling line-number-at-pos so many times was unnecessary and using a lot
    of cpu
---
 vdiff.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/vdiff.el b/vdiff.el
index d93ccb2..e8c9cff 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -733,16 +733,19 @@ buffer and center both buffers at this line."
       (let* ((in-b (eq window win-b))
              (other-window (if in-b win-a win-b))
              (other-buffer (if in-b buf-a buf-b))
-             (this-line (line-number-at-pos (point)))
-             (other-line (vdiff--translate-line
-                          this-line in-b))
-             (other-line-pos (vdiff--pos-at-line-beginning
-                              other-line other-buffer))
              (this-start  (line-number-at-pos window-start))
-             (other-start (vdiff--translate-line
-                           this-start in-b))
-             (other-start-pos (vdiff--pos-at-line-beginning
-                               other-start other-buffer))
+             (other-start (vdiff--translate-line this-start in-b))
+             (other-start-pos
+              (with-current-buffer other-buffer
+                (vdiff--move-to-line other-start)
+                (line-beginning-position)))
+             (this-line (+ (count-lines window-start (point))
+                           this-start))
+             (other-line (vdiff--translate-line this-line in-b))
+             (other-line-pos
+              (with-current-buffer other-buffer
+                (forward-line (- other-line other-start))
+                (line-beginning-position)))
              (vdiff--in-scroll-hook t))
         (set-window-start other-window other-start-pos)
         (set-window-point other-window other-line-pos)))))



reply via email to

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