From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/59337 Path: main.gmane.org!not-for-mail From: Nelson Ferreira Newsgroups: gmane.emacs.gnus.general,gmane.emacs.devel Subject: [PATCH] Load spam-stat hashtable only when there are changes in the disk file Date: Sun, 05 Dec 2004 11:55:48 -0500 Organization: - none - Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1102265988 885 80.91.229.6 (5 Dec 2004 16:59:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 5 Dec 2004 16:59:48 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: ding-owner+M7877@lists.math.uh.edu Sun Dec 05 17:59:36 2004 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13] ident=mail) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CazjT-0002FD-00 for ; Sun, 05 Dec 2004 17:59:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1CazgH-0005OB-00; Sun, 05 Dec 2004 10:56:17 -0600 Original-Received: from util2.math.uh.edu ([129.7.128.23]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1Cazg7-0005O3-00 for ding@lists.math.uh.edu; Sun, 05 Dec 2004 10:56:07 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by util2.math.uh.edu with esmtp (Exim 4.30) id 1Cazg4-0006YT-O3 for ding@lists.math.uh.edu; Sun, 05 Dec 2004 10:56:04 -0600 Original-Received: from main.gmane.org (main.gmane.org [80.91.229.2]) by justine.libertine.org (Postfix) with ESMTP id 0B3F03A0036 for ; Sun, 5 Dec 2004 10:56:01 -0600 (CST) Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1Cazfz-0008PB-00 for ; Sun, 05 Dec 2004 17:55:59 +0100 Original-Received: from pool-68-237-71-238.ny325.east.verizon.net ([68.237.71.238]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 05 Dec 2004 17:55:59 +0100 Original-Received: from nelson.ferreira by pool-68-237-71-238.ny325.east.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 05 Dec 2004 17:55:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: ding@gnus.org Original-Lines: 164 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pool-68-237-71-238.ny325.east.verizon.net User-Agent: Gnus/5.110003 (No Gnus v0.3) XEmacs/21.5 (chestnut, linux) Cancel-Lock: sha1:meRukuVQ/AJcLl5er/LY0UmnAhA= Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: main.gmane.org gmane.emacs.gnus.general:59337 gmane.emacs.devel:30704 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:59337 --=-=-= This patch prevents spam-stat from doing unnecessary loads of the hashtable to memory. 2004-12-05 Nelson Ferreira * spam-stat.el (spam-stat-save): Load the hashtable from disk only if there is no hashtable in memory or file modification time is newer than cached timestamp. --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: attachment; filename=gnus-spam-stat.el.patch Content-Description: Load spam-stat hashtable only when there are changes in the disk file Content-Transfer-Encoding: quoted-printable Index: lisp/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v retrieving revision 7.554 diff -u -u -b -r7.554 ChangeLog --- lisp/ChangeLog 3 Dec 2004 15:58:17 -0000 7.554 +++ lisp/ChangeLog 5 Dec 2004 16:52:53 -0000 @@ -1,3 +1,9 @@ +2004-12-05 Nelson Ferreira + + * spam-stat.el (spam-stat-save): Load the hashtable from disk only + if there is no hashtable in memory or file modification time is + newer than cached timestamp. + 2004-12-03 Reiner Steib =20 * gnus-sum.el (gnus-summary-limit-to-recipient): Implement @@ -161,7 +167,7 @@ =20 * gnus-art.el (gnus-header-button-alist): Handle URLs in OpenPGP: headers separately. - (gnus-button-openpgp): New function, inspired by Jochen K=FCpper + (gnus-button-openpgp): New function, inspired by Jochen K=FCpper . =20 2004-11-14 Reiner Steib @@ -1881,7 +1887,7 @@ (spam-mark-new-messages-in-spam-group-as-spam): allow user to disable assigning the spam-mark to new messages (spam-ham-copy-or-move-routine): todo decleared twice (tiny - change). From Adam Sj=F8gren . + change). From Adam Sj=F8gren . =20 2004-05-26 Katsumi Yamaoka =20 @@ -2021,7 +2027,7 @@ (spam-crm114-unregister-spam-routine) (spam-crm114-register-ham-routine) (spam-crm114-unregister-ham-routine): add CRM114 support. From - asjo@koldfront.dk (Adam Sj=F8gren). + asjo@koldfront.dk (Adam Sj=F8gren). =20 * gnus.el: added spam-use-crm114 =20 @@ -2462,7 +2468,7 @@ 2004-04-22 Teodor Zlatanov =20 From Dan Christensen , asjo@koldfront.dk (Adam - Sj=F8gren), Wes Hardaker , and Michael Shields + Sj=F8gren), Wes Hardaker , and Michael Shields : =20=09 * spam.el (spam-necessary-extra-headers): get the extra headers we @@ -2480,7 +2486,7 @@ 2004-04-21 Teodor Zlatanov =20 * spam.el (spam-summary-prepare-exit): logic and message fix. - Reported by bojohan+news@dd.chalmers.se (Johan Bockg=E5rd). + Reported by bojohan+news@dd.chalmers.se (Johan Bockg=E5rd). =20 2004-04-17 Jesper Harder =20 @@ -3625,7 +3631,7 @@ =20 * gnus-score.el (gnus-score-edit-all-score): Fix prototype. Invoke gnus-score-mode. Reported by - bojohan+news@dd.chalmers.se (Johan Bockg=E5rd). + bojohan+news@dd.chalmers.se (Johan Bockg=E5rd). =20 * gnus-range.el (gnus-compress-sequence): Doc fix. Suggested by Jim Blandy (tiny change). @@ -3982,7 +3988,7 @@ =20 * nnheaderxm.el: Remove definition of run-at-time. =20 -2004-01-05 Karl Pfl=E4sterer +2004-01-05 Karl Pfl=E4sterer =20 * mml.el (mml-minibuffer-read-disposition): Show attachment type in prompt (tiny change) Index: lisp/spam-stat.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/local/cvsroot/gnus/lisp/spam-stat.el,v retrieving revision 7.19 diff -u -u -b -r7.19 spam-stat.el --- lisp/spam-stat.el 2 Nov 2004 02:54:22 -0000 7.19 +++ lisp/spam-stat.el 5 Dec 2004 16:52:54 -0000 @@ -186,6 +186,9 @@ this filter, re-training spam-stat with several thousand messages will start to take a very long time.") =20 +(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) @@ -389,6 +392,7 @@ (interactive "P") (when (or force spam-stat-dirty) (let ((coding-system-for-write spam-stat-coding-system)) + (message "Saving %s..." spam-stat-file) (with-temp-file spam-stat-file (let ((standard-output (current-buffer)) (font-lock-maximum-size 0)) @@ -401,14 +405,25 @@ (spam-stat-bad entry)))) spam-stat) (insert ")))")))) - (setq spam-stat-dirty nil))) + (message "Saved %s." spam-stat-file) + (setq spam-stat-dirty nil + spam-stat-last-saved-at (nth 5 (file-attributes spam-stat-file))= ))) =20 (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 (not (boundp 'spam-stat-last-saved-at)) + (null spam-stat-last-saved-at) + (not (equal spam-stat-last-saved-at + (nth 5 (file-attributes spam-stat-file))))) + (progn=20 + (load-file spam-stat-file) + (setq spam-stat-dirty nil + spam-stat-last-saved-at=20 + (nth 5 (file-attributes spam-stat-file))))) + (t (message "Spam stat file not loaded: no change in disk.."))))) =20 (defun spam-stat-to-hash-table (entries) "Turn list ENTRIES into a hash table and store as `spam-stat'. --=-=-= -- Nelson Ferreira --=-=-=--