[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage cea4662 4/4: Maybe-optimize disk-usage--list
From: |
Pierre Neidhardt |
Subject: |
[elpa] externals/disk-usage cea4662 4/4: Maybe-optimize disk-usage--list-recursively |
Date: |
Sat, 2 Mar 2019 08:51:43 -0500 (EST) |
branch: externals/disk-usage
commit cea46628bcc0681281d78cdd0f5da34f81752d90
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Maybe-optimize disk-usage--list-recursively
It does not seem to make a difference locally. Maybe remotely.
---
disk-usage.el | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index 8312ba0..622ab05 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -298,25 +298,24 @@ $ find . -type f -exec du -sb {} +"
(setq directory (or directory default-directory))
(let* ((default-directory directory)
;; Note: Cannot use `process-lines' if we want to work on remote
hosts.
- (pair-strings (split-string
+ (subdirs (split-string
(with-temp-buffer
(process-file disk-usage-find-command nil '(t nil)
nil
(file-local-name directory)
- "-type" "f"
- "-exec"
- disk-usage-du-command
- disk-usage-du-args "{}" "+")
+ "-type" "d")
(buffer-string))
"\n" 'omit-nulls)))
- (cl-loop for pair-string in pair-strings
- for pair = (split-string pair-string "\t")
- for name = (concat (file-remote-p directory) (cadr pair))
- for attributes = (file-attributes name)
- when (cl-loop for filter in disk-usage-filters
- always (funcall filter name attributes))
- collect (disk-usage--file-info-make
- :name name
- :size (string-to-number (cl-first pair))))))
+ (cl-loop for dir in subdirs
+ append (cl-loop for file in (directory-files-and-attributes dir
'full nil 'nosort)
+ for name = (concat (file-remote-p directory) (car
file))
+ for attributes = (cdr file)
+ when (and attributes
+ (not (file-attribute-type attributes))
+ (cl-loop for filter in
disk-usage-filters
+ always (funcall filter name
attributes)))
+ collect (disk-usage--file-info-make
+ :name name
+ :size (file-attribute-size
attributes))))))
(defcustom disk-usage-list-function #'disk-usage--list
"Function that returns a list of `disk-usage--file-info'.