unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: 36857@debbugs.gnu.org
Subject: bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
Date: Wed, 25 Dec 2019 18:31:07 +0200	[thread overview]
Message-ID: <0f42bb71-b460-1ec7-f24f-e2df50cb5f70@yandex.ru> (raw)
In-Reply-To: <8736inuzb3.fsf@ericabrahamsen.net>

[-- Attachment #1: Type: text/plain, Size: 95 bytes --]

Hi Eric,

Please try the attached patch. It should cut down on the number of 
process calls.



[-- Attachment #2: dired-do-find-regexp-speedup.diff --]
[-- Type: text/x-patch, Size: 1585 bytes --]

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index fb1ad6266d..0fb8839a3f 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2975,19 +2975,24 @@ dired-do-find-regexp
   (require 'xref)
   (defvar grep-find-ignored-files)
   (declare-function rgrep-find-ignored-directories "grep" (dir))
-  (let* ((files (dired-get-marked-files nil nil nil nil t))
+  (let* ((marks (dired-get-marked-files nil nil nil nil t))
          (ignores (nconc (mapcar
                           #'file-name-as-directory
                           (rgrep-find-ignored-directories default-directory))
                          grep-find-ignored-files))
          (fetcher
           (lambda ()
-            (let ((xrefs (mapcan
-                          (lambda (file)
-                            (xref-collect-matches regexp "*" file
-                                                  (and (file-directory-p file)
-                                                       ignores)))
-                          files)))
+            (let (files xrefs)
+              (mapc
+               (lambda (mark)
+                 (if (file-directory-p mark)
+                     (setq files (nconc
+                                  (project--files-in-directory mark ignores "*")
+                                  files))
+                   (push mark files)))
+               (nreverse marks))
+              (setq xrefs
+                    (project--find-regexp-in-files regexp files))
               (unless xrefs
                 (user-error "No matches for: %s" regexp))
               xrefs))))


  parent reply	other threads:[~2019-12-25 16:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 17:20 bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp Eric Abrahamsen
2019-07-30 18:44 ` Dmitry Gutov
2019-07-30 18:45   ` Dmitry Gutov
2019-07-30 18:56     ` Eric Abrahamsen
2019-07-31 14:06       ` Dmitry Gutov
2019-07-31 15:56         ` Eric Abrahamsen
2019-12-25 16:31       ` Dmitry Gutov [this message]
2019-12-25 21:46         ` Eric Abrahamsen
2019-12-26 16:00           ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f42bb71-b460-1ec7-f24f-e2df50cb5f70@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=36857@debbugs.gnu.org \
    --cc=eric@ericabrahamsen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).