From: João Távora Date: Mon, 1 Feb 2021 17:23:07 +0000 (+0000) Subject: Speed up glob matching 2x X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~169 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=aa4e58409c6c7a394a9a1292b1f5e34d5377323d;p=emacs.git 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 --- 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