Gnus development mailing list
 help / color / mirror / Atom feed
From: Nelson Ferreira <nelson.ferreira@verizon.net>
Subject: [PATCH] Only load .spam-stat.el if needed
Date: Tue, 01 Jun 2004 18:32:45 -0400	[thread overview]
Message-ID: <7971.11302749744$1086129226@news.gmane.org> (raw)



I noticed a huge delay on every news update because of spam-stat-load,
which had to load everytime a (now) huge file.

This patch attempts to only load when the file was not loaded before,
or somehow it changed on disk:

Please use at will.

diff -u -r7.16 spam-stat.el
--- spam-stat.el        20 May 2004 08:02:41 -0000      7.16
+++ spam-stat.el        1 Jun 2004 22:30:15 -0000
@@ -185,6 +185,9 @@
 this filter, re-training spam-stat with several thousand messages
 will start to take a very long time.")

+(defvar spam-stat-last-saved-at nil
+  "Time stamp of last change of spam-stat-file on this run")
+
 (defvar spam-stat-syntax-table
   (let ((table (copy-syntax-table text-mode-syntax-table)))
     (modify-syntax-entry ?- "w" table)
@@ -400,14 +403,24 @@
                                  (spam-stat-bad entry))))
                   spam-stat)
          (insert ")))"))))
-       (setq spam-stat-dirty nil)))
+       (setq spam-stat-dirty nil)
+       (setq spam-stat-last-saved-at (nth 5 (file-attributes spam-stat-file)))))

 (defun spam-stat-load ()
   "Read the `spam-stat' hash table from disk."
   ;; TODO: maybe we should warn the user if spam-stat-dirty is t?
   (let ((coding-system-for-read spam-stat-coding-system))
-    (load-file spam-stat-file))
-  (setq spam-stat-dirty nil))
+    (cond (spam-stat-dirty (message "Spam stat not loaded: spam-stat-dirty t"))
+         ((or (null spam-stat-last-saved-at)
+              (not (boundp 'spam-stat-last-saved-at))
+              (not (equal spam-stat-last-saved-at
+                          (nth 5 (file-attributes spam-stat-file)))))
+          (progn
+            (load-file spam-stat-file)
+            (setq spam-stat-dirty nil)
+            (setq spam-stat-last-saved-at
+                  (nth 5 (file-attributes spam-stat-file)))))
+         (t (message "Spam stat file not loaded: no change in disk..")))))

 (defun spam-stat-to-hash-table (entries)
   "Turn list ENTRIES into a hash table and store as `spam-stat'.


-- 
Nelson Ferreira



                 reply	other threads:[~2004-06-01 22:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='7971.11302749744$1086129226@news.gmane.org' \
    --to=nelson.ferreira@verizon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).