From 544db1ee8679eec9edd5cee81a340ee1c4d70158 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 15 Sep 2021 13:47:15 +0200 Subject: [PATCH] Faster grep pattern for identifiers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/cedet/semantic/symref/grep.el (semantic-symref-perform-search): Use the `-w` flag instead of wrapping the pattern in regexps that make matching much slower. This speeds up `xref-find-references` by about 3× on macOS. --- lisp/cedet/semantic/symref/grep.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index cee54d78185..e06a3c10078 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -150,15 +150,8 @@ This shell should support pipe redirect syntax." "-l ") ((eq (oref tool searchtype) 'regexp) "-nE ") - (t "-n "))) - (greppat (cond ((eq (oref tool searchtype) 'regexp) - (oref tool searchfor)) - (t - ;; Can't use the word boundaries: Grep - ;; doesn't always agree with the language - ;; syntax on those. - (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" - (oref tool searchfor))))) + (t "-nw "))) + (greppat (oref tool searchfor)) ;; Misc (b (get-buffer-create "*Semantic SymRef*")) (ans nil) -- 2.39.5