diff lisp/gnus/mm-util.el @ 110171:a05bc4ad2d3f

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.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 04 Sep 2010 00:45:13 +0000
parents 8d09094063d0
children ab3a38ccb842
line wrap: on
line diff
--- a/lisp/gnus/mm-util.el	Sat Sep 04 00:36:13 2010 +0000
+++ b/lisp/gnus/mm-util.el	Sat Sep 04 00:45:13 2010 +0000
@@ -1429,16 +1429,23 @@
 	;; Reset the umask.
 	(set-default-file-modes umask)))))
 
+(defvar mm-image-load-path-cache nil)
+
 (defun mm-image-load-path (&optional package)
-  (let (dir result)
-    (dolist (path load-path (nreverse result))
-      (when (and path
-		 (file-directory-p
-		  (setq dir (concat (file-name-directory
-				     (directory-file-name path))
-				    "etc/images/" (or package "gnus/")))))
-	(push dir result))
-      (push path result))))
+  (if (and mm-image-load-path-cache
+	   (equal load-path (car mm-image-load-path-cache)))
+      (cdr mm-image-load-path-cache)
+    (let (dir result)
+      (dolist (path load-path)
+	(when (and path
+		   (file-directory-p
+		    (setq dir (concat (file-name-directory
+				       (directory-file-name path))
+				      "etc/images/" (or package "gnus/")))))
+	  (push dir result)))
+      (setq result (nreverse result)
+	    mm-image-load-path-cache (cons load-path result))
+      result)))
 
 ;; Fixme: This doesn't look useful where it's used.
 (if (fboundp 'detect-coding-region)