Gnus development mailing list
 help / color / mirror / Atom feed
From: Dan Christensen <jdc+news@uwo.ca>
Subject: faster gnus-summary-from-or-to-or-newsgroups
Date: Sun, 02 Sep 2001 00:34:48 -0400	[thread overview]
Message-ID: <8766b2gqhj.fsf@uwo.ca> (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


             reply	other threads:[~2001-09-02  4:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-02  4:34 Dan Christensen [this message]
2001-09-30  0:50 ` Dan Christensen
2001-09-30 11:00   ` Simon Josefsson

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=8766b2gqhj.fsf@uwo.ca \
    --to=jdc+news@uwo.ca \
    /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).