[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-editor 53a6b8a: with-editor-sleeping-editor-filter: L
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/with-editor 53a6b8a: with-editor-sleeping-editor-filter: Limit length of saved output |
Date: |
Sat, 18 Dec 2021 15:58:32 -0500 (EST) |
branch: elpa/with-editor
commit 53a6b8ad8a6aabea3749366fb11f12a7dabcb11f
Author: Yikai Zhao <yikai@z1k.dev>
Commit: Jonas Bernoulli <jonas@bernoul.li>
with-editor-sleeping-editor-filter: Limit length of saved output
Improve performance by limitting the maximum length of the string
saved in process filters.
While using with `vterm', this `incomplete' string may get very
large and it hurts performance. In my case, it can easily get to few
megabytes after using the same terminal for a long time, which would
then increase the latency of each keystroke significantly. We should
only need to keep the last few bytes to make it work.
---
lisp/with-editor.el | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lisp/with-editor.el b/lisp/with-editor.el
index c0bf1dd..fcb3854 100644
--- a/lisp/with-editor.el
+++ b/lisp/with-editor.el
@@ -644,12 +644,19 @@ may not insert the text into the PROCESS's buffer. Then
it calls
(defconst with-editor-sleeping-editor-regexp
"^WITH-EDITOR: \\([0-9]+\\) OPEN \\([^]+?\\)\\(?: IN
\\([^\r]+?\\)\\)?\r?$")
+(defvar with-editor--max-incomplete-length 1000)
+
(defun with-editor-sleeping-editor-filter (process string)
(when-let ((incomplete (and process (process-get process 'incomplete))))
(setq string (concat incomplete string)))
(save-match-data
(cond
((and process (not (string-match-p "\n\\'" string)))
+ (let ((length (length string)))
+ (when (> length with-editor--max-incomplete-length)
+ (setq string
+ (substring string
+ (- length with-editor--max-incomplete-length)))))
(process-put process 'incomplete string)
nil)
((string-match with-editor-sleeping-editor-regexp string)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/with-editor 53a6b8a: with-editor-sleeping-editor-filter: Limit length of saved output,
ELPA Syncer <=