branch: externals/eglot
commit 8d00f8b639cb15687440cb0c301bd700727e02d6
Author: João Távora <[email protected]>
Commit: João Távora <[email protected]>
Per #602: 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.
---
eglot.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eglot.el b/eglot.el
index 44648ae..50fb695 100644
--- a/eglot.el
+++ b/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