[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cf4ccc58284: Speed up duplicate-line by a factor of 2
From: |
Mattias Engdegård |
Subject: |
master cf4ccc58284: Speed up duplicate-line by a factor of 2 |
Date: |
Tue, 27 Jun 2023 11:35:59 -0400 (EDT) |
branch: master
commit cf4ccc58284de50959ea66b1cd2655ab2fa4d15b
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Speed up duplicate-line by a factor of 2
* lisp/misc.el (duplicate-line): Add the newline to the string to be
inserted instead of inserting it separately.
This makes duplicate-line as fast as duplicate-dwim with a contiguous
region. Both could easily be made faster yet by making the code more
complex.
---
lisp/misc.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lisp/misc.el b/lisp/misc.el
index 81769696f95..de82b97fa6f 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -71,13 +71,15 @@ Also see the `copy-from-above-command' command."
(interactive "p")
(unless n
(setq n 1))
- (let ((line (buffer-substring (line-beginning-position)
(line-end-position))))
+ (let ((line (concat (buffer-substring (line-beginning-position)
+ (line-end-position))
+ "\n")))
(save-excursion
(forward-line 1)
(unless (bolp)
(insert "\n"))
(dotimes (_ n)
- (insert line "\n")))))
+ (insert line)))))
(declare-function rectangle--duplicate-right "rect" (n))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master cf4ccc58284: Speed up duplicate-line by a factor of 2,
Mattias Engdegård <=