From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs 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 Message-ID: <0f42bb71-b460-1ec7-f24f-e2df50cb5f70@yandex.ru> References: <87wofzv3px.fsf@ericabrahamsen.net> <43928735-8d95-de13-74e6-96f4b1b3e1bd@yandex.ru> <26938345-f9bb-1c92-fedf-e59fdb536f77@yandex.ru> <8736inuzb3.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------9206BD6875C43B8C55FFF47D" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="230592"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: 36857@debbugs.gnu.org To: Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 25 17:32:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ik9Zz-000xsT-K3 for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2019 17:32:11 +0100 Original-Received: from localhost ([::1]:47576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ik9Zx-0001My-T8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2019 11:32:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60979) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ik9Zr-0001LX-JB for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 11:32:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ik9Zq-0006uR-Di for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 11:32:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48653) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ik9Zq-0006uJ-9E for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 11:32:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ik9Zq-00041I-6i for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 11:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Dec 2019 16:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36857 X-GNU-PR-Package: emacs Original-Received: via spool by 36857-submit@debbugs.gnu.org id=B36857.157729147715399 (code B ref 36857); Wed, 25 Dec 2019 16:32:02 +0000 Original-Received: (at 36857) by debbugs.gnu.org; 25 Dec 2019 16:31:17 +0000 Original-Received: from localhost ([127.0.0.1]:54626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ik9Z7-00040J-3j for submit@debbugs.gnu.org; Wed, 25 Dec 2019 11:31:17 -0500 Original-Received: from mail-lf1-f49.google.com ([209.85.167.49]:33046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ik9Z6-000408-AD for 36857@debbugs.gnu.org; Wed, 25 Dec 2019 11:31:16 -0500 Original-Received: by mail-lf1-f49.google.com with SMTP id n25so17096590lfl.0 for <36857@debbugs.gnu.org>; Wed, 25 Dec 2019 08:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=L4YznNs7yNaKl/fVYr/0zthpLH+8KBh15FX1OGdBonM=; b=sa+ktAz4csiU03/bBYeuanYER2mZWUO90jMZgr/aparMF+8rYesi8U8o2DbvHqIx2f /KfZKy3XU0gHGDrZ4+ZJSuRvcsUrfkp0Ou35SOKDpHGrZCA6NiTpJ5JkebcC/TVjpBMV qvHK/o3qWN796Catny+VJDr/L1HqFISEpChRBb8sKUKMWHwAdejGpJH+boBPLAYI2ObM uhC1/ym/SFIQqUGQUdjZq7bznTB0bSzGn97rlxZEp+oE4kdD4SXdarRoBhfUrsZQUceO WJ7Pk8tnslM4TpXiPX4orsfyipOm9/k0jOZE+MmizayFSpaGx7cDGNwqyDh2T6pSjsnG 4gHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:subject:to:cc:references:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=L4YznNs7yNaKl/fVYr/0zthpLH+8KBh15FX1OGdBonM=; b=nKFolO9i0/BneCwkr+7gslmjz/gWeioLCfZSKt8oAFe5wD0M61yOfwfyUsDlnsY2S0 gxJsW/lYkb5W2BnPeubei5susp5aKyrNNiZIpQWLrQhTIvWOwFZ+qY5vfsOfl4XuaYw4 jVYltb9nwedcQvuHKc4MJ9ADpWzv0NDvr1KwlJRTB5EuqKA+74Ff8Jlwy/+k9eyDBsk4 dUGBe24fMCEVD5gv8syOwOnXSpP0b8EQNZAl8bG2z8vBduj2wi2yI05gWr3V915y9/wh XGfXE7tP7YhEEjtaFRva5+9+xcVXqOLlt0Q6MSr/YOEMVe6CYa4eIus7ru6BqqlyS1Xr /wxA== X-Gm-Message-State: APjAAAUgE93v4tCKZtY4csFDqcSKz/IWvwWwfvG09yAhhvLtaKagzGaA iK/vTgu0hC49F3Ql9xCiGDCPShZFEogUKw== X-Google-Smtp-Source: APXvYqz9HWPJz/qWzslkhGs7yR+jw/Jum4bUe9cDDQuay2vyuYRzmFCQgMNmqd25ex2DZBsFkHgvgg== X-Received: by 2002:a19:6d13:: with SMTP id i19mr23766183lfc.6.1577291470404; Wed, 25 Dec 2019 08:31:10 -0800 (PST) Original-Received: from [172.18.118.211] ([79.104.7.197]) by smtp.googlemail.com with ESMTPSA id 138sm11925300lfa.76.2019.12.25.08.31.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Dec 2019 08:31:09 -0800 (PST) In-Reply-To: <8736inuzb3.fsf@ericabrahamsen.net> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173753 Archived-At: This is a multi-part message in MIME format. --------------9206BD6875C43B8C55FFF47D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Eric, Please try the attached patch. It should cut down on the number of process calls. --------------9206BD6875C43B8C55FFF47D Content-Type: text/x-patch; name="dired-do-find-regexp-speedup.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dired-do-find-regexp-speedup.diff" 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)))) --------------9206BD6875C43B8C55FFF47D--