Gnus development mailing list
 help / color / mirror / Atom feed
* faster gnus-thread-latest-date
@ 2009-12-07 21:27 Dan Christensen
  2009-12-08  3:35 ` Dan Christensen
  0 siblings, 1 reply; 18+ messages in thread
From: Dan Christensen @ 2009-12-07 21:27 UTC (permalink / raw)
  To: ding

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




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-06-10  8:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-07 21:27 faster gnus-thread-latest-date Dan Christensen
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

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).