From c1276860bc356c49bea590ddc8f0b8239d6ae790 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Mon, 11 Feb 2008 22:48:02 +0000 Subject: [PATCH] Cache the keys by which messages are ordered in a hash table, so that we need not repeatedly fetch and parse header fields and such for the same messages. (The cache may be optionally disabled by passing a switch to MAKE-FOLDER-ORDER if it is concluded superfluous.) --- v7/src/imail/imail-core.scm | 128 +++++++++++++++++++++++------------- 1 file changed, 81 insertions(+), 47 deletions(-) diff --git a/v7/src/imail/imail-core.scm b/v7/src/imail/imail-core.scm index c30752ae3..264a9dde1 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.166 2008/01/30 20:02:09 cph Exp $ +$Id: imail-core.scm,v 1.167 2008/02/11 22:48:02 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -735,11 +735,23 @@ USA. (define-structure (folder-order (type-descriptor ) - (constructor make-folder-order (predicate selector))) + (constructor %make-folder-order (predicate selector cache))) (predicate #f read-only #t) (selector #f read-only #t) + (cache #f read-only #t) (tree #f)) +(define (make-folder-order predicate selector #!optional cache?) + (%make-folder-order predicate + selector + (and (or (default-object? cache?) cache?) + (make-integer-hash-table)))) + +(define (reset-folder-order! order) + (set-folder-order-tree! order #f) + (let ((cache (folder-order-cache order))) + (if cache (hash-table/clear! cache)))) + (define (map-folder-index folder index) (let ((order (folder-order folder))) (if order @@ -757,13 +769,11 @@ USA. (begin (memoize-folder-order order folder) (or (wt-tree/rank (folder-order-tree order) - (cons ((folder-order-selector order) - (%get-message folder index)) - index)) + (index-order-key folder order index)) index)) index))) -(define (make-wt-message-tree key