[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/undo-fu-session 7bbc89a42f 36/53: Build linear-list in-ord
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/undo-fu-session 7bbc89a42f 36/53: Build linear-list in-order instead of reversing |
Date: |
Thu, 7 Jul 2022 12:05:25 -0400 (EDT) |
branch: elpa/undo-fu-session
commit 7bbc89a42f6bb4abcd4513488bd45784cf4041e4
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Build linear-list in-order instead of reversing
This can be slightly faster.
---
undo-fu-session.el | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/undo-fu-session.el b/undo-fu-session.el
index 2b091100c9..78f1f87902 100755
--- a/undo-fu-session.el
+++ b/undo-fu-session.el
@@ -96,19 +96,24 @@ Enforcing removes the oldest files."
This gives the same behavior as running `undo-only',
ignoring all branches that aren't included in the current undo state."
- (let ((linear-list nil))
- (while
- ;; Collapse all redo branches (giving the same results as if running
`undo-only')
- (let ((undo-list-next nil))
- (while (setq undo-list-next (gethash undo-list equiv-table))
- (setq undo-list undo-list-next))
- (and undo-list (not (eq t undo-list))))
-
- ;; Pop all steps until the next boundary 'nil'.
- (let ((undo-elt t))
- (while undo-elt
- (setq undo-elt (pop undo-list))
- (push undo-elt linear-list))))
+ (let ((linear-list (cons nil nil)))
+ ;; Store the last `cons' cell to build a list in-order
+ ;; (saves pushing to the front of the list then reversing).
+ (let ((tail-cdr linear-list))
+ (while
+ ;; Collapse all redo branches (giving the same results as if running
`undo-only')
+ (let ((undo-list-next nil))
+ (while (setq undo-list-next (gethash undo-list equiv-table))
+ (setq undo-list undo-list-next))
+ (and undo-list (not (eq t undo-list))))
+
+ ;; Pop all steps until the next boundary 'nil'.
+ (let ((undo-elt t))
+ (while undo-elt
+ (setq undo-elt (pop undo-list))
+ (setq tail-cdr (setcdr tail-cdr (cons undo-elt nil))))))
+ ;; Remove the place holder `cons' cell.
+ (setq linear-list (cdr linear-list)))
;; Pass through 'nil', when there is no undo information.
;; Also convert '(list nil)' to 'nil', since this is no undo info too.
@@ -117,7 +122,7 @@ ignoring all branches that aren't included in the current
undo state."
;; to when there are no undo steps yet.
(cond
((and linear-list (not (equal (list nil) linear-list)))
- (nreverse linear-list))
+ linear-list)
(t
nil))))
- [nongnu] elpa/undo-fu-session f9589be462 22/53: Global mode is no longer enables in special-modes, (continued)
- [nongnu] elpa/undo-fu-session f9589be462 22/53: Global mode is no longer enables in special-modes, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 2424ad50ff 04/53: Use 'string-match-p' to avoid changing match data, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 35d4cf3771 07/53: Update commentary to make it more useful., ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session e2043f8350 10/53: Add `undo-fu-session-linear` option, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 39f9b1997e 13/53: Ignore encrypted files by default, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session fddcc75a58 01/53: Initial commit., ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 98a8cc6396 14/53: Add missing docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 243d93b4c7 21/53: Cleanup: formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session dae6dfbc7d 28/53: Cleanup: docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session a6a23301a4 30/53: Fix #2: resolve potential security issue with file permissions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 7bbc89a42f 36/53: Build linear-list in-order instead of reversing,
ELPA Syncer <=
- [nongnu] elpa/undo-fu-session 2fe1efcfa1 37/53: Shorten message, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 5862b90b9c 38/53: Cleanup: use file-name-concat for clarity, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 56d3134287 40/53: Cleanup: use simpler syntax to construct the overlay list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 4330e87aac 50/53: Remove undo-fu-session hooks when no buffers have the mode enabled, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 3e54374b37 52/53: Cleanup: use double-dash for private functions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session fa4833d470 02/53: readme: update to reference other packages, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session fa62a9b9a1 03/53: Cleanup: messages & docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 049fe942f6 11/53: Cleanup: order buffer-undo-list before pending-undo-list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 5cc4b4f33d 12/53: Fix for linearizing an empty undo-list disabling undo on reload, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 56cdd3538a 16/53: Don't show common-place messages in the echo area, ELPA Syncer, 2022/07/07