From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Date: Wed, 13 Mar 2024 11:01:05 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9876"; mail-complaints-to="usenet@ciao.gmane.io" To: 69775@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 13 16:02:56 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkQ87-0002Kg-2a for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Mar 2024 16:02:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkQ7h-00082c-6Z; Wed, 13 Mar 2024 11:02:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkQ7f-000828-Mz for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:02:27 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkQ7f-0004Ab-6q for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:02:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rkQ8D-0003ri-Vh for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Mar 2024 15:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171034212514780 (code B ref -1); Wed, 13 Mar 2024 15:03:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Mar 2024 15:02:05 +0000 Original-Received: from localhost ([127.0.0.1]:47156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkQ7I-0003qJ-NA for submit@debbugs.gnu.org; Wed, 13 Mar 2024 11:02:05 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkQ7F-0003pn-UR for submit@debbugs.gnu.org; Wed, 13 Mar 2024 11:02:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkQ6U-0007u3-Dp for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:01:14 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkQ6R-0003xm-KQ for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:01:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1710342065; bh=0dKb2rRziZA8F7lSAnUzu8Far3qakV9aYzgOJicYr4k=; h=From:To:Subject:Date; b=y9YnsPHLTQesumYxUGjBtco9HqAaJHvlF18uYk628ZJbxjWY1h8q6c/AZ+nzg8eUf sCKNLu+HAIu8DZRaHBzJzCQ+0hvaE1vCljHZzC+VVWo/jCs3u3l4fsVkTCTlPIL37U znf35o7BhVPBm5mb5In8e8odSkmgiJPmHB7NHSO3DlprrA9f13IHY/4at6c9Hb2h0t kCOxggssMWV6o1iuDSY4gQBb3p/rMacwnNC/N/zUvss0Izm/qhUvA1YJKglraYqc9L yYK4HIxWR+YkevWx2us9fTI6vJJzYl69M0Ll4ald9ABjUJd/XYoAooTr/zN95pB974 hI3DyKXxsxDJw== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281551 Archived-At: --=-=-= Content-Type: text/plain Tags: patch In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (dired-omit-size-limit): Increase, since omitting is now faster. In GNU Emacs 29.2.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-02-28 built on igm-qws-u22796a Repository revision: 46e23709d37943a20faa735c97af520196a443e9 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure 'CFLAGS=-O0 -g3' --with-gif=ifavailable --with-x-toolkit=lucid' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Use-regexp-opt-in-dired-omit-regexp.patch >From f8e3318cab3b3975040efc37225c79c272c4dabe Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 13 Mar 2024 10:57:44 -0400 Subject: [PATCH] Use regexp-opt in dired-omit-regexp In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (dired-omit-size-limit): Increase, since omitting is now faster. --- lisp/dired-x.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 5a494569989..aa4320a393e 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -77,12 +77,12 @@ dired-vm-read-only-folders (other :tag "non-writable only" if-file-read-only)) :group 'dired-x) -(defcustom dired-omit-size-limit 100000 +(defcustom dired-omit-size-limit 300000 "Maximum size for the \"omitting\" feature. If nil, there is no maximum size." :type '(choice (const :tag "no maximum" nil) integer) :group 'dired-x - :version "29.1") + :version "30.1") (defcustom dired-omit-case-fold 'filesystem "Determine whether \"omitting\" patterns are case-sensitive. @@ -504,14 +504,23 @@ dired-omit-expunge (re-search-forward dired-re-mark nil t)))) count))) +(defvar dired-omit--extension-regexp-cache + nil + "A cache of `regexp-opt' applied to `dired-omit-extensions'. + +This is a cons whose car is a list of strings and whose cdr is a +regexp produced by `regexp-opt'.") + (defun dired-omit-regexp () + (unless (equal dired-omit-extensions (car dired-omit--extension-regexp-cache)) + (setq dired-omit--extension-regexp-cache + (cons dired-omit-extensions (regexp-opt dired-omit-extensions)))) (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") (if (and dired-omit-files dired-omit-extensions) "\\|" "") (if dired-omit-extensions (concat ".";; a non-extension part should exist - "\\(" - (mapconcat 'regexp-quote dired-omit-extensions "\\|") - "\\)$") + (cdr dired-omit--extension-regexp-cache) + "$") ""))) ;; Returns t if any work was done, nil otherwise. -- 2.39.3 --=-=-=--