From e646cb4e7a46132a7717a94fe3632ecb03f080fc Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Thu, 23 Sep 2021 21:40:36 +0300 Subject: [PATCH] A bit less overhead when converting hits * lisp/progmodes/xref.el (xref--collect-matches): Move 'remote-id' and 'syntax-needed' definitions to the caller function. Bind 'inhibit-modification-hooks' to t (bug#50733). --- lisp/progmodes/xref.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 62f66b2018a..fb8090cfb72 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1831,18 +1831,20 @@ Such as the current syntax table and the applied syntax properties." (defun xref--convert-hits (hits regexp) (let (xref--last-file-buffer - (tmp-buffer (generate-new-buffer " *xref-temp*"))) + (tmp-buffer (generate-new-buffer " *xref-temp*")) + (remote-id (file-remote-p default-directory)) + (syntax-needed (xref--regexp-syntax-dependent-p regexp))) (unwind-protect - (mapcan (lambda (hit) (xref--collect-matches hit regexp tmp-buffer)) + (mapcan (lambda (hit) + (xref--collect-matches hit regexp tmp-buffer remote-id syntax-needed)) hits) (kill-buffer tmp-buffer)))) -(defun xref--collect-matches (hit regexp tmp-buffer) +(defun xref--collect-matches (hit regexp tmp-buffer remote-id syntax-needed) (pcase-let* ((`(,line ,file ,text) hit) - (remote-id (file-remote-p default-directory)) (file (and file (concat remote-id file))) (buf (xref--find-file-buffer file)) - (syntax-needed (xref--regexp-syntax-dependent-p regexp))) + (inhibit-modification-hooks t)) (if buf (with-current-buffer buf (save-excursion -- 2.39.2