function.
* gnus-util.el (gnus-cache-file-contents): New function.
* gnus-agent.el (gnus-agent-file-loading-cache): New variable.
(gnus-agent-load-alist): Use it.
* nnagent.el (nnagent-retrieve-headers): Use optimized function.
* nnheader.el (nnheader-insert-nov-file): New function.
2002-01-26 Lars Magne Ingebrigtsen <larsi@gnus.org>
+ * gnus-agent.el (gnus-agent-load-alist): Use new caching
+ function.
+
+ * gnus-util.el (gnus-cache-file-contents): New function.
+
+ * gnus-agent.el (gnus-agent-file-loading-cache): New variable.
+ (gnus-agent-load-alist): Use it.
+
+ * nnagent.el (nnagent-retrieve-headers): Use optimized function.
+
+ * nnheader.el (nnheader-insert-nov-file): New function.
+
* gnus-util.el (gnus-parse-without-error): Correct the loop.
* gnus-sum.el (gnus-dependencies-add-header): Use in-reply-to if
(defvar gnus-agent-file-name nil)
(defvar gnus-agent-send-mail-function nil)
(defvar gnus-agent-file-coding-system 'raw-text)
+(defvar gnus-agent-file-loading-cache nil)
;; Dynamic variables
(defvar gnus-headers)
(defun gnus-agent-load-alist (group &optional dir)
"Load the article-state alist for GROUP."
+ (let ((file ))
(setq gnus-agent-article-alist
- (gnus-agent-read-file
+ (gnus-cache-file-contents
(if dir
- (expand-file-name ".agentview" dir)
- (gnus-agent-article-name ".agentview" group)))))
+ (expand-file-name ".agentview" dir)
+ (gnus-agent-article-name ".agentview" group))
+ 'gnus-agent-file-loading-cache
+ 'gnus-agent-read-file))))
(defun gnus-agent-save-alist (group &optional articles state dir)
"Save the article-state alist for GROUP."
(count-lines (point-min) (point)))
(forward-line 1)))))
+(defun gnus-cache-file-contents (file variable function)
+ "Cache the contents of FILE in VARIABLE. The contents come from FUNCTION."
+ (let ((time (nth 5 (file-attributes file)))
+ contents value)
+ (if (or (null (setq value (symbol-value variable)))
+ (not (equalp (car value) file))
+ (not (equalp (nth 1 value) time)))
+ (progn
+ (setq contents (funcall function file))
+ (set variable (list file time contents))
+ contents)
+ (nth 2 value))))
+
(provide 'gnus-util)
;;; gnus-util.el ends here
(mapcar 'car gnus-agent-article-alist)))
(set-buffer nntp-server-buffer)
(erase-buffer)
- (nnheader-insert-file-contents file)
+ (nnheader-insert-nov-file file (car articles))
(goto-char (point-min))
(gnus-parse-without-error
(while arts
(let ((coding-system-for-read nnheader-file-coding-system))
(mm-insert-file-contents filename visit beg end replace)))
+(defun nnheader-insert-nov-file (file first)
+ (let ((size (nth 7 (file-attributes file))))
+ (if (< size 4096)
+ ;; If the file is small, we just load it.
+ (nnheader-insert-file-contents file)
+ ;; We start on the assumption that FIRST is pretty recent. If
+ ;; not, we just insert the rest of the file as well.
+ (let (current)
+ (nnheader-insert-file-contents file nil (- size 8192) size)
+ (goto-char (point-min))
+ (delete-region (point) (or (search-forward "\n" nil 'move) (point)))
+ (setq current (ignore-errors (read (current-buffer))))
+ (if (and (numberp current)
+ (< current first))
+ t
+ (delete-region (point-min) (point-max))
+ (nnheader-insert-file-contents file))))))
+
(defun nnheader-find-file-noselect (&rest args)
(let ((format-alist nil)
(auto-mode-alist (mm-auto-mode-alist))