From aa4e58409c6c7a394a9a1292b1f5e34d5377323d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 1 Feb 2021 17:23:07 +0000 Subject: [PATCH] Speed up glob matching 2x with-temp-buffer was taking a lot of time, presumably because it kills the buffer. Since emacs is single-threaded, we can safely reuse a single buffer. * eglot.el (eglot--glob-parse): Simplify grammar. (eglot--glob-compile): Don't with-temp-buffer. GitHub-reference: per https://github.com/joaotavora/eglot/issues/602 --- lisp/progmodes/eglot.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 44648ae41b4..50fb695319a 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2672,10 +2672,9 @@ at point. With prefix argument, prompt for ACTION-KIND." with grammar = '((:** "\\*\\*/?" eglot--glob-emit-**) (:* "\\*" eglot--glob-emit-*) (:? "\\?" eglot--glob-emit-?) - (:/ "/" eglot--glob-emit-self) (:{} "{[^][/*{}]+}" eglot--glob-emit-{}) (:range "\\[\\^?[^][/,*{}]+\\]" eglot--glob-emit-range) - (:literal "[^][/,*?{}]+" eglot--glob-emit-self)) + (:literal "[^][,*?{}]+" eglot--glob-emit-self)) until (eobp) collect (cl-loop for (_token regexp emitter) in grammar @@ -2687,7 +2686,8 @@ at point. With prefix argument, prompt for ACTION-KIND." "Convert GLOB into Elisp function. Maybe BYTE-COMPILE it. If NOERROR, return predicate, else erroring function." (let* ((states (eglot--glob-parse glob)) - (body `(with-temp-buffer + (body `(with-current-buffer (get-buffer-create " *eglot-glob-matcher*") + (erase-buffer) (save-excursion (insert string)) (cl-labels ,(cl-loop for (this that) on states for (self emit text) = this -- 2.39.5