From: Spencer Baugh <sbaugh@janestreet.com>
To: 69775@debbugs.gnu.org
Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp
Date: Wed, 13 Mar 2024 11:01:05 -0400 [thread overview]
Message-ID: <ier7ci6kwge.fsf@janestreet.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 939 bytes --]
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'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-regexp-opt-in-dired-omit-regexp.patch --]
[-- Type: text/patch, Size: 2570 bytes --]
From f8e3318cab3b3975040efc37225c79c272c4dabe Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
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
next reply other threads:[~2024-03-13 15:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 15:01 Spencer Baugh [this message]
2024-03-14 11:00 ` bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Eli Zaretskii
2024-03-16 17:15 ` sbaugh
2024-03-21 10:38 ` Eli Zaretskii
2024-03-23 13:29 ` sbaugh
2024-03-23 17:11 ` Eli Zaretskii
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=ier7ci6kwge.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=69775@debbugs.gnu.org \
/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).