Subject: Re: bug#6810: 23.2; dired-omit-mode makes dired slow

From: Leo <[email-masked]>
Date: Sat, 04 Dec 2010 17:34:21 +0000

On 2010-08-06 16:19 +0100, Leo wrote:
> When dired-omit-mode is on, operations on marked files become much
> slower. To see this, following these steps:
>
> 1. Emacs -q
>
> 2. eval:
>   (require 'dired-x)
>   (add-hook 'dired-mode-hook 'dired-omit-mode)
>
> 3. C-x d and enter emacs/lisp (or any dir that has a few dozen files)
>
> 4. Mark all files by typing: * / t
>
> 5. Change mode to 444 by typing: M 444 RET
>
>
> For every marked file, a message is displayed something like:
>    Redisplaying...xyz.el
>    Omitting...
>    (Nothing to omit)
>
> Can this inefficiency be rid of? Thank you.
>
> Leo

`dired-do-redisplay' iterates over the marked files calling
dired-update-file-line which triggers dired-after-readin-hook (see line
1132 in dired-aux). So that hook is being run for as many times as the
number of files marked.

Any objection to something like this:

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 62d6928..90fd1e69 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1017,10 +1017,13 @@
     ;; message much faster than making dired-map-over-marks show progress
     (dired-uncache
      (if (consp dired-directory) (car dired-directory) dired-directory))
-    (dired-map-over-marks (let ((fname (dired-get-filename)))
+    (dired-map-over-marks (let ((fname (dired-get-filename))
+                                ;; disable readin hook until later
+                                (dired-after-readin-hook nil))
 			    (message "Redisplaying... %s" fname)
 			    (dired-update-file-line fname))
 			  arg)
+    (run-hooks 'dired-after-readin-hook)
     (dired-move-to-filename)
     (message "Redisplaying...done")))
 
Leo