[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/popup 717c81eb3d 1/3: Make popup-replace-displayable much
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/popup 717c81eb3d 1/3: Make popup-replace-displayable much faster |
Date: |
Tue, 27 Sep 2022 12:59:22 -0400 (EDT) |
branch: elpa/popup
commit 717c81eb3d32e2e33ee75c813399909351d463b0
Author: gcv <gepardcv@gmail.com>
Commit: GitHub <noreply@github.com>
Make popup-replace-displayable much faster
One of my users reported a performance bug, which I tracked down to
`popup-replace-displayable` (https://github.com/gcv/julia-snail/issues/110).
Calling `popup-replace-displayable` takes ~3 seconds on a string of about
8000 characters on my system, and becomes much slower on larger inputs.
The attached PR eliminates the large number of string concatenations and
significantly improves the function's performance.
---
popup.el | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/popup.el b/popup.el
index c65118da6a..31ed9e92b5 100644
--- a/popup.el
+++ b/popup.el
@@ -244,15 +244,15 @@ ITEM is not string."
Optional argument REP is the replacement string of
non-displayable character."
- (unless rep (setq rep ""))
- (let ((result ""))
+ (let ((rep (or rep ""))
+ (results (list)))
(dolist (string (split-string str ""))
(let* ((char (string-to-char string))
(string (if (char-displayable-p char)
string
rep)))
- (setq result (concat result string))))
- result))
+ (push string results)))
+ (string-join (reverse results))))
(cl-defun popup-make-item (name
&key