Gnus development mailing list
 help / color / mirror / Atom feed
* faster gnus-summary-from-or-to-or-newsgroups
@ 2001-09-02  4:34 Dan Christensen
  2001-09-30  0:50 ` Dan Christensen
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Christensen @ 2001-09-02  4:34 UTC (permalink / raw)


I've managed to increase the speed of summary buffer generation
by about 20% by rewriting gnus-summary-from-or-to-or-newsgroups
(the %n spec).

The original function is:

(defun gnus-summary-from-or-to-or-newsgroups (header)
  (let ((to (cdr (assq 'To (mail-header-extra header))))
	(newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
	(mail-parse-charset gnus-newsgroup-charset)
	(mail-parse-ignored-charsets
	 (save-excursion (set-buffer gnus-summary-buffer)
			 gnus-newsgroup-ignored-charsets)))
    (cond
     ((and to
	   gnus-ignored-from-addresses
	   (string-match gnus-ignored-from-addresses
			 (mail-header-from header)))
      (concat "-> "
	      (or (car (funcall gnus-extract-address-components
				(funcall
				 gnus-decode-encoded-word-function to)))
		  (funcall gnus-decode-encoded-word-function to))))
     ((and newsgroups
	   gnus-ignored-from-addresses
	   (string-match gnus-ignored-from-addresses
			 (mail-header-from header)))
      (concat "=> " newsgroups))
     (t
      (or (car (funcall gnus-extract-address-components
			(mail-header-from header)))
	  (mail-header-from header))))))

The changes I made are:

1) call mail-header-extra only if needed, and at most once
2) don't do the string-match more than once
3) don't call gnus-decode-encode-word-function more than once
4) use gnus-tmp-from instead of (mail-header-from header)

The result is:

(defun gnus-summary-extract-address-component (from)
  (or (car (funcall gnus-extract-address-components from))
      from))

(defun gnus-summary-from-or-to-or-newsgroups (header)
  (let ((mail-parse-charset gnus-newsgroup-charset)
	; Is it really necessary to do this next part for each summary line?
	; Luckily, doesn't seem to slow things down much.
	(mail-parse-ignored-charsets
	 (save-excursion (set-buffer gnus-summary-buffer)
			 gnus-newsgroup-ignored-charsets)))
    (or
     (and gnus-ignored-from-addresses
	  (string-match gnus-ignored-from-addresses gnus-tmp-from)
	  (let ((extra-headers (mail-header-extra header))
		to
		newsgroups)
	    (cond
	     ((setq to (cdr (assq 'To extra-headers)))
	      (concat "-> "
		      (gnus-summary-extract-address-component
		       (funcall gnus-decode-encoded-word-function to))))
	     ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
	      (concat "=> " newsgroups)))))
     (gnus-summary-extract-address-component gnus-tmp-from))))

If there are no complaints, could someone apply this?

The bottleneck is probably now in mail-extract-address-components
(what I have gnus-extract-address-components set to).  Does someone
want to tackle speeding that up without reducing its accuracy?

Also, I noticed that removing the %d spec speeds up the generation of
my summary buffers by about 30%!  Does anyone want to try speeding up
the corresponding function?

-- 
Dan Christensen
jdc+news@uwo.ca


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

end of thread, other threads:[~2001-09-30 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-02  4:34 faster gnus-summary-from-or-to-or-newsgroups Dan Christensen
2001-09-30  0:50 ` Dan Christensen
2001-09-30 11:00   ` Simon Josefsson

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