From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/57796 Path: main.gmane.org!not-for-mail From: Nelson Ferreira Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Only load .spam-stat.el if needed Date: Tue, 01 Jun 2004 18:32:45 -0400 Sender: ding-owner@lists.math.uh.edu Message-ID: <7971.11302749744$1086129226@news.gmane.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1086129226 20375 80.91.224.253 (1 Jun 2004 22:33:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 1 Jun 2004 22:33:46 +0000 (UTC) Original-X-From: ding-owner+M6337@lists.math.uh.edu Wed Jun 02 00:33:41 2004 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BVHpE-0000Wv-00 for ; Wed, 02 Jun 2004 00:33:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1BVHoX-0004TU-00; Tue, 01 Jun 2004 17:32:57 -0500 Original-Received: from util2.math.uh.edu ([129.7.128.23]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1BVHoQ-0004TO-00 for ding@lists.math.uh.edu; Tue, 01 Jun 2004 17:32:50 -0500 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by util2.math.uh.edu with esmtp (Exim 4.30) id 1BVHoN-0007uY-J5 for ding@lists.math.uh.edu; Tue, 01 Jun 2004 17:32:47 -0500 Original-Received: from tuxie.homelinux.net (pool-68-237-120-213.ny325.east.verizon.net [68.237.120.213]) by justine.libertine.org (Postfix) with ESMTP id 633A63A0036 for ; Tue, 1 Jun 2004 17:32:46 -0500 (CDT) Original-Received: (from njsf@localhost) by tuxie.homelinux.net (8.11.6/8.9.3) id i51MWjo17324; Tue, 1 Jun 2004 17:32:45 -0500 X-Msgid-Archive-Tag: _-nf--_xmat_-m:gnus_--- Original-To: ding@gnus.org X-Attribution: njsf User-Agent: Gnus/5.110003 (No Gnus v0.3) XEmacs/21.5 (chayote, linux) Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:57796 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:57796 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