aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2010-09-04 00:45:13 +0000
committerKatsumi Yamaoka2010-09-04 00:45:13 +0000
commiteecdcaf581984698081637f2f8ce0f0a0f701de0 (patch)
tree9faeb11062b27d3ddd5a30918b7c8bb40dbf6c66
parent8fab3e398d5759069a6f12584fda35d227906364 (diff)
downloademacs-eecdcaf581984698081637f2f8ce0f0a0f701de0.tar.gz
emacs-eecdcaf581984698081637f2f8ce0f0a0f701de0.zip
mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
-rw-r--r--lisp/gnus/ChangeLog10
-rw-r--r--lisp/gnus/mm-util.el25
-rw-r--r--lisp/gnus/nnmh.el35
3 files changed, 47 insertions, 23 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 4ad4fe4e117..c18cf19aaed 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,15 @@
12010-09-04 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * nnmh.el (nnmh-request-list-1): Optimize for speed.
4
12010-09-03 Lars Magne Ingebrigtsen <larsi@gnus.org> 52010-09-03 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 6
7 * mm-util.el (mm-image-load-path): Just return the image directories,
8 not all directories in the path in addition to the image directories.
9 (mm-image-load-path): Maintain a cache of the image directories so that
10 the `g' command in Gnus doesn't have to stat dozens of directories each
11 time.
12
3 * gnus-html.el (gnus-html-put-image): Allow images to be removed. 13 * gnus-html.el (gnus-html-put-image): Allow images to be removed.
4 (gnus-html-wash-tags): Add a new `i' command to insert images. 14 (gnus-html-wash-tags): Add a new `i' command to insert images.
5 (gnus-html-insert-image): New command and keystroke. 15 (gnus-html-insert-image): New command and keystroke.
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index da5d96d51f2..588915a1ab7 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -1429,16 +1429,23 @@ If SUFFIX is non-nil, add that at the end of the file name."
1429 ;; Reset the umask. 1429 ;; Reset the umask.
1430 (set-default-file-modes umask))))) 1430 (set-default-file-modes umask)))))
1431 1431
1432(defvar mm-image-load-path-cache nil)
1433
1432(defun mm-image-load-path (&optional package) 1434(defun mm-image-load-path (&optional package)
1433 (let (dir result) 1435 (if (and mm-image-load-path-cache
1434 (dolist (path load-path (nreverse result)) 1436 (equal load-path (car mm-image-load-path-cache)))
1435 (when (and path 1437 (cdr mm-image-load-path-cache)
1436 (file-directory-p 1438 (let (dir result)
1437 (setq dir (concat (file-name-directory 1439 (dolist (path load-path)
1438 (directory-file-name path)) 1440 (when (and path
1439 "etc/images/" (or package "gnus/"))))) 1441 (file-directory-p
1440 (push dir result)) 1442 (setq dir (concat (file-name-directory
1441 (push path result)))) 1443 (directory-file-name path))
1444 "etc/images/" (or package "gnus/")))))
1445 (push dir result)))
1446 (setq result (nreverse result)
1447 mm-image-load-path-cache (cons load-path result))
1448 result)))
1442 1449
1443;; Fixme: This doesn't look useful where it's used. 1450;; Fixme: This doesn't look useful where it's used.
1444(if (fboundp 'detect-coding-region) 1451(if (fboundp 'detect-coding-region)
diff --git a/lisp/gnus/nnmh.el b/lisp/gnus/nnmh.el
index 05eb669fa0b..86f751c7669 100644
--- a/lisp/gnus/nnmh.el
+++ b/lisp/gnus/nnmh.el
@@ -207,21 +207,29 @@ as unread by Gnus.")
207(defun nnmh-request-list-1 (dir) 207(defun nnmh-request-list-1 (dir)
208 (setq dir (expand-file-name dir)) 208 (setq dir (expand-file-name dir))
209 ;; Recurse down all directories. 209 ;; Recurse down all directories.
210 (let ((dirs (and (file-readable-p dir) 210 (let ((files (nnheader-directory-files dir t nil t))
211 (nnheader-directory-files dir t nil t))) 211 (max 0)
212 rdir) 212 min rdir attributes num)
213 ;; Recurse down directories. 213 ;; Recurse down directories.
214 (while (setq rdir (pop dirs)) 214 (dolist (rdir files)
215 (when (and (file-directory-p rdir) 215 (setq attributes (file-attributes rdir))
216 (when (null (nth 0 attributes))
217 (setq file (file-name-nondirectory rdir))
218 (when (string-match "^[0-9]+$" file)
219 (setq num (string-to-number file))
220 (setq max (max max num))
221 (when (or (null min)
222 (< num min))
223 (setq min num))))
224 (when (and (eq (nth 0 attributes) t) ; Is a directory
225 (> (nth 1 attributes) 2) ; Has sub-directories
216 (file-readable-p rdir) 226 (file-readable-p rdir)
217 (not (equal (file-truename rdir) 227 (not (equal (file-truename rdir)
218 (file-truename dir)))) 228 (file-truename dir))))
219 (nnmh-request-list-1 rdir)))) 229 (nnmh-request-list-1 rdir)))
220 ;; For each directory, generate an active file line. 230 ;; For each directory, generate an active file line.
221 (unless (string= (expand-file-name nnmh-toplev) dir) 231 (unless (string= (expand-file-name nnmh-toplev) dir)
222 (let ((files (mapcar 'string-to-number 232 (when min
223 (directory-files dir nil "^[0-9]+$" t))))
224 (when files
225 (with-current-buffer nntp-server-buffer 233 (with-current-buffer nntp-server-buffer
226 (goto-char (point-max)) 234 (goto-char (point-max))
227 (insert 235 (insert
@@ -233,14 +241,13 @@ as unread by Gnus.")
233 (file-truename (file-name-as-directory 241 (file-truename (file-name-as-directory
234 (expand-file-name nnmh-toplev)))) 242 (expand-file-name nnmh-toplev))))
235 dir) 243 dir)
236 (mm-string-to-multibyte ;Why? Isn't it multibyte already? 244 (mm-string-to-multibyte ;Why? Isn't it multibyte already?
237 (mm-encode-coding-string 245 (mm-encode-coding-string
238 (nnheader-replace-chars-in-string 246 (nnheader-replace-chars-in-string
239 (substring dir (match-end 0)) 247 (substring dir (match-end 0))
240 ?/ ?.) 248 ?/ ?.)
241 nnmail-pathname-coding-system))) 249 nnmail-pathname-coding-system)))
242 (apply 'max files) 250 max min))))))
243 (apply 'min files)))))))
244 t) 251 t)
245 252
246(deffoo nnmh-request-newgroups (date &optional server) 253(deffoo nnmh-request-newgroups (date &optional server)