From 72e98bdfce7905fdc08cb5400b663fc956e66d87 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Sun, 11 Mar 2007 01:11:41 +0000 Subject: [PATCH] New implementation of folder orders that uses AVL trees instead of sorted vectors to store the order of messages. Modifications to the folder are now reflected in incremental updates to the folder order by AVL insertions, instead of rebuilding the order vector for every modification to the folder. Also, the key by which the message is sorted is now computed once per message in the order record, instead of every time that the message comparison predicate is called. --- v7/src/imail/imail-core.scm | 104 ++++++++++++++++++++++++------------ v7/src/imail/imail-top.scm | 7 +-- v7/src/imail/load.scm | 3 +- 3 files changed, 74 insertions(+), 40 deletions(-) diff --git a/v7/src/imail/imail-core.scm b/v7/src/imail/imail-core.scm index 7621e8f1a..ba61aa6b5 100644 --- a/v7/src/imail/imail-core.scm +++ b/v7/src/imail/imail-core.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: imail-core.scm,v 1.156 2007/01/05 21:19:25 cph Exp $ +$Id: imail-core.scm,v 1.157 2007/03/11 01:11:19 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -410,7 +410,12 @@ USA. (define set-folder-order! (let ((modifier (slot-modifier 'ORDER))) (lambda (folder order) - (modifier folder order) + (let ((original-order (folder-order folder))) + (modifier folder order) + (cond ((not (and original-order order)) + (receive-modification-events folder update-folder-order)) + ((not (or original-order order)) + (ignore-modification-events folder update-folder-order)))) (object-modified! folder 'REORDERED)))) (define-class ()) @@ -724,21 +729,18 @@ USA. (define-structure (folder-order (type-descriptor ) - (constructor make-folder-order (predicate))) + (constructor make-folder-order (predicate selector))) (predicate #f read-only #t) - (forward #f) - (reverse #f) - (modification-count -1)) + (selector #f read-only #t) + (tree #f)) (define (map-folder-index folder index) (let ((order (folder-order folder))) (if order (begin (memoize-folder-order order folder) - (let ((v (folder-order-forward order))) - (if (fix:< index (vector-length v)) - (vector-ref v index) - index))) + (%message-index + (wt-tree/index-datum (folder-order-tree order) index))) index))) (define (unmap-folder-index folder index) @@ -746,33 +748,67 @@ USA. (if order (begin (memoize-folder-order order folder) - (let ((v (folder-order-reverse order))) - (if (fix:< index (vector-length v)) - (vector-ref v index) - index))) + (wt-tree/rank (folder-order-tree order) + (cons ((folder-order-selector order) + (%get-message folder index)) + index))) index))) +(define (make-wt-message-tree key