From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/21119 Path: main.gmane.org!not-for-mail From: Shenghuo ZHU Newsgroups: gmane.emacs.gnus.general Subject: Rewrite gnus-range-add Date: 10 Feb 1999 01:25:49 -0500 Organization: Computer Dept of U Rochester Sender: owner-ding@hpc.uh.edu Message-ID: <2nu2wudbbm.fsf@zsh.cs.rochester.edu> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035159286 21344 80.91.224.250 (21 Oct 2002 00:14:46 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 00:14:46 +0000 (UTC) Return-Path: Original-Received: from spinoza.math.uh.edu (spinoza.math.uh.edu [129.7.128.18]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id BAA22746 for ; Wed, 10 Feb 1999 01:38:03 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by spinoza.math.uh.edu (8.9.1/8.9.1) with ESMTP id AAB16512; Wed, 10 Feb 1999 00:36:22 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Wed, 10 Feb 1999 00:36:18 -0600 (CST) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.7.3/8.7.3) with ESMTP id AAA14706 for ; Wed, 10 Feb 1999 00:36:08 -0600 (CST) Original-Received: from cayuga.cs.rochester.edu (cayuga.cs.rochester.edu [192.5.53.209]) by sclp3.sclp.com (8.8.5/8.8.5) with SMTP id BAA22668 for ; Wed, 10 Feb 1999 01:36:00 -0500 (EST) Original-Received: from slate.cs.rochester.edu (slate.cs.rochester.edu [192.5.53.101]) by cayuga.cs.rochester.edu (8.6.9/P) with ESMTP id BAA20557 for ; Wed, 10 Feb 1999 01:35:39 -0500 Original-Received: from brain.cs.rochester.edu (heart.cs.rochester.edu [192.5.53.109]) by slate.cs.rochester.edu (8.6.9/P) with ESMTP id BAA09841 for ; Wed, 10 Feb 1999 01:35:35 -0500 Original-Received: (from zsh@localhost) by brain.cs.rochester.edu (8.9.0/8.8.5) id BAA02675; Wed, 10 Feb 1999 01:25:49 -0500 Original-To: gnus X-Attribution: ZSH X-Face: 'IF:e51ib'Qbl^(}l^&4-J`'P!@[4~O|&k#:@Gld#b/]oMq&`&FVY._3+b`mzp~Jeve~/#/ ERD!OTe<86UhyN=l`mrPY)M7_}`Ktt\K+58Z!hu7>qU,i.N7TotU[FYE(f1;}`g2xj!u*l`^&=Q!g{ *q|ddto|nkt"$r,K$[)"|6,elPH= GJ6Q Original-Lines: 92 User-Agent: Gnus/5.070075 (Pterodactyl Gnus v0.75) XEmacs/20.4 (Emerald) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:21119 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:21119 gnus-agent-expire caused X crash! When gnus-agent-expire calls gnus-range-add, which uncompresses an extremely large range, such as ("misc.jobs.offered" 3 (1 . 10809366)), memory is used up. A patch is attached. Wed Feb 10 01:03:43 1999 Shenghuo ZHU * gnus-range.el (gnus-range-add): Rewrite. -- Shenghuo --- gnus-range.el 1999/02/10 06:02:05 1.1 +++ gnus-range.el 1999/02/10 06:02:39 @@ -326,19 +326,59 @@ sublistp)) (defun gnus-range-add (range1 range2) - "Add RANGE2 to RANGE1 destructively." - (cond - ;; If either are nil, then the job is quite easy. - ((or (null range1) (null range2)) - (or range1 range2)) - (t - ;; I don't like thinking. - (gnus-compress-sequence - (sort - (nconc - (gnus-uncompress-range range1) - (gnus-uncompress-range range2)) - '<))))) + "Add RANGE2 to RANGE1 (nondestructively)." + (unless (listp (cdr range1)) + (setq range1 (list range1))) + (unless (listp (cdr range2)) + (setq range2 (list range2))) + (let ((item1 (pop range1)) + (item2 (pop range2)) + range item selector) + (while (or item1 item2) + (setq selector + (cond + ((null item1) nil) + ((null item2) t) + ((and (numberp item1) (numberp item2)) (< item1 item2)) + ((numberp item1) (< item1 (car item2))) + ((numberp item2) (< (car item1) item2)) + (t (< (car item1) (car item2))))) + (setq item + (or + (let ((tmp1 item) (tmp2 (if selector item1 item2))) + (cond + ((null tmp1) tmp2) + ((null tmp2) tmp1) + ((and (numberp tmp1) (numberp tmp2)) + (cond + ((eq tmp1 tmp2) tmp1) + ((eq (1+ tmp1) tmp2) (cons tmp1 tmp2)) + ((eq (1+ tmp2) tmp1) (cons tmp2 tmp1)) + (t nil))) + ((numberp tmp1) + (cond + ((and (>= tmp1 (car tmp2)) (<= tmp1 (cdr tmp2))) tmp2) + ((eq (1+ tmp1) (car tmp2)) (cons tmp1 (cdr tmp2))) + ((eq (1- tmp1) (cdr tmp2)) (cons (car tmp2) tmp1)) + (t nil))) + ((numberp tmp2) + (cond + ((and (>= tmp2 (car tmp1)) (<= tmp2 (cdr tmp1))) tmp1) + ((eq (1+ tmp2) (car tmp1)) (cons tmp2 (cdr tmp1))) + ((eq (1- tmp2) (cdr tmp1)) (cons (car tmp1) tmp2)) + (t nil))) + ((< (1+ (cdr tmp1)) (car tmp2)) nil) + ((< (1+ (cdr tmp2)) (car tmp1)) nil) + (t (cons (min (car tmp1) (car tmp2)) + (max (cdr tmp1) (cdr tmp2)))))) + (progn + (if item (push item range)) + (if selector item1 item2)))) + (if selector + (setq item1 (pop range1)) + (setq item2 (pop range2)))) + (if item (push item range)) + (reverse range))) (provide 'gnus-range)