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

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

[elpa] externals/vundo 1b98c3708c 33/58: * vundo.el (vundo--eqv-merge):


From: ELPA Syncer
Subject: [elpa] externals/vundo 1b98c3708c 33/58: * vundo.el (vundo--eqv-merge): Replace nth for performance.
Date: Fri, 15 Apr 2022 12:58:14 -0400 (EDT)

branch: externals/vundo
commit 1b98c3708c0c204f45b8685e44772f358b20c8e0
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    * vundo.el (vundo--eqv-merge): Replace nth for performance.
---
 vundo.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/vundo.el b/vundo.el
index 94b7d03375..eec59cc3c6 100644
--- a/vundo.el
+++ b/vundo.el
@@ -312,12 +312,16 @@ modification in MOD-LIST. Return HASH-TABLE."
 (defun vundo--eqv-merge (mlist)
   "Connect modifications in MLIST to be in the same equivalence list.
 Order is reserved."
-  (cl-loop for idx from 0 to (1- (length mlist))
-           for this = (nth idx mlist)
-           for next = (nth (1+ idx) mlist)
-           for prev = nil then (nth (1- idx) mlist)
-           do (setf (vundo-m-prev-eqv this) prev)
-           do (setf (vundo-m-next-eqv this) next)))
+  ;; Basically, for MLIST = (A B C), set
+  ;; A.prev = nil  A.next = B
+  ;; B.prev = A    B.next = C
+  ;; C.prev = B    C.next = nil
+  (cl-loop for this-tail = mlist then (cdr this-tail)
+           for next-tail = (cdr mlist) then (cdr next-tail)
+           for prev-tail = (cons nil mlist) then (cdr prev-tail)
+           while this-tail
+           do (setf (vundo-m-prev-eqv (car this-tail)) (car prev-tail))
+           do (setf (vundo-m-next-eqv (car this-tail)) (car next-tail))))
 
 (defun vundo--sort-mod (mlist &optional reverse)
   "Return sorted modifications in MLIST by their idx...



reply via email to

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