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

* Re: faster gnus-summary-from-or-to-or-newsgroups
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Christensen @ 2001-09-30  0:50 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

Dan Christensen <jdc+news@uwo.ca> writes:

> 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 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 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?

I signed and sent in my copyright assignment papers a couple of weeks
ago.  I've attached the above change as a patch.  Could someone apply
it?

Dan

-- 
Dan Christensen
jdc+news@uwo.ca


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus-sum.el.patch --]
[-- Type: text/x-patch, Size: 2186 bytes --]

--- gnus-sum.el.orig	Sat Sep 29 20:29:42 2001
+++ gnus-sum.el.jdc	Sat Sep 29 20:45:54 2001
@@ -2904,32 +2904,31 @@
    (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
    (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
 
+(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 ((to (cdr (assq 'To (mail-header-extra header))))
-	(newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
-	(mail-parse-charset gnus-newsgroup-charset)
+  (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)))
-    (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))))))
+    (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))))
 
 (defun gnus-summary-insert-line (gnus-tmp-header
 				 gnus-tmp-level gnus-tmp-current

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

* Re: faster gnus-summary-from-or-to-or-newsgroups
  2001-09-30  0:50 ` Dan Christensen
@ 2001-09-30 11:00   ` Simon Josefsson
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Josefsson @ 2001-09-30 11:00 UTC (permalink / raw)


Dan Christensen <jdc+news@uwo.ca> writes:

>> 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?

Use `gnus-extract-address-components' instead?  I think it is supposed
to be faster.

> I signed and sent in my copyright assignment papers a couple of weeks
> ago.  I've attached the above change as a patch.  Could someone apply
> it?

Applied, thanks!




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