Commit c9e3deff authored by Lars Magne Ingebrigtsen's avatar Lars Magne Ingebrigtsen
Browse files

Speed up directory-files-recursively

* files.el (directory-files-recursively): Use
`file-name-all-completions' instead of `directory-files' for
greater speed.
parent ef8892db
2014-12-10 Lars Magne Ingebrigtsen <larsi@gnus.org> 2014-12-10 Lars Magne Ingebrigtsen <larsi@gnus.org>
   
* files.el (directory-files-recursively): Use
`file-name-all-completions' instead of `directory-files' for
greater speed.
* net/shr.el (shr-tag-object): Don't bug out on text elements in * net/shr.el (shr-tag-object): Don't bug out on text elements in
<object>. <object>.
   
......
...@@ -769,18 +769,21 @@ and alphabetical order. ...@@ -769,18 +769,21 @@ and alphabetical order.
If INCLUDE-DIRECTORIES, also include directories that have matching names." If INCLUDE-DIRECTORIES, also include directories that have matching names."
(let ((result nil) (let ((result nil)
(files nil)) (files nil))
(dolist (file (directory-files dir t)) (dolist (file (sort (file-name-all-completions "" dir)
(let ((leaf (file-name-nondirectory file))) 'string<))
(unless (member leaf '("." "..")) (unless (member file '("./" "../"))
(if (file-directory-p file) (if (= (aref file (1- (length file))) ?/)
(progn (progn
(when (and include-directories
(string-match match leaf))
(push file files))
(setq result (nconc result (directory-files-recursively (setq result (nconc result (directory-files-recursively
file match include-directories)))) (expand-file-name file dir)
(when (string-match match leaf) match include-directories)))
(push file files)))))) (when (and include-directories
(string-match match
(substring file 0 (1- (length file)))))
(setq result (nconc result (list
(expand-file-name file dir))))))
(when (string-match match file)
(push (expand-file-name file dir) files)))))
(nconc result (nreverse files)))) (nconc result (nreverse files))))
(defun load-file (file) (defun load-file (file)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment