Gnus development mailing list
 help / color / mirror / Atom feed
From: Dan Christensen <jdc@uwo.ca>
To: ding@gnus.org
Subject: faster gnus-thread-latest-date
Date: Mon, 07 Dec 2009 16:27:44 -0500	[thread overview]
Message-ID: <87my1uiien.fsf@uwo.ca> (raw)

The function gnus-thread-latest-date is used by
gnus-thread-sort-by-most-recent-date, and is very slow.  The current
code is:

(defun gnus-thread-latest-date (thread)
  "Return the highest article date in THREAD."
  (let ((previous-time 0))
    (apply 'max
	   (mapcar
	    (lambda (header)
	      (setq previous-time
		    (condition-case ()
			(gnus-float-time (mail-header-parse-date
					  (mail-header-date header)))
		      (error previous-time))))
	    (sort
	     (message-flatten-list thread)
	     (lambda (h1 h2)
	       (< (mail-header-number h1)
		  (mail-header-number h2))))))))

Since all that is desired is the latest date, I don't see why dates that
don't parse are replaced by the date of the article with the previous
number.  Why not just replace them with zero?  And if you do that, then
there is no need for a preliminary sort by number.  So I think the
following version should produce identical output:

(defun gnus-thread-latest-date (thread)
  "Return the highest article date in THREAD."
  (apply 'max
	 (mapcar
	  (lambda (header)
	    (condition-case ()
		(gnus-float-time (mail-header-parse-date
				  (mail-header-date header)))
	      (error 0)))
	  (message-flatten-list thread))))

Can someone check my logic?

In my tests, it is noticeable faster.  Can it be improved further?

I have papers on file for Gnus and Emacs, so feel free to apply
this change.

Dan




             reply	other threads:[~2009-12-07 21:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07 21:27 Dan Christensen [this message]
2009-12-08  3:35 ` Dan Christensen
2009-12-08  7:07   ` Katsumi Yamaoka
2009-12-08 19:14   ` Ted Zlatanov
2009-12-09  0:33     ` Dan Christensen
2009-12-10  3:03       ` Dan Christensen
2009-12-11  3:01         ` Dan Christensen
2009-12-11 22:03           ` Dan Christensen
2009-12-13 23:25             ` Dan Christensen
2009-12-14 16:18               ` Dave Love
2009-12-13 23:56           ` Dan Christensen
2010-01-02  2:09             ` Dan Christensen
2010-01-12 17:17               ` Reiner Steib
2010-06-09 13:42             ` Dan Christensen
2010-06-10  0:32               ` Katsumi Yamaoka
2010-06-10  8:42                 ` Gnus new commits (was: faster gnus-thread-latest-date) Ted Zlatanov
2009-12-13 10:29   ` faster gnus-thread-latest-date Daniel Pittman
2009-12-13 23:38     ` Dan Christensen

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=87my1uiien.fsf@uwo.ca \
    --to=jdc@uwo.ca \
    --cc=ding@gnus.org \
    /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).