From: Chris Hanson Date: Thu, 29 Sep 2005 19:15:54 +0000 (+0000) Subject: In HASH-TABLE/COUNT, rehash the table if it needs it -- this is the X-Git-Tag: 20090517-FFI~1217 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=55d28e938eb78093f16a0ce1f1fa98ebc95112e8;p=mit-scheme.git In HASH-TABLE/COUNT, rehash the table if it needs it -- this is the only way to guarantee an accurate count. --- diff --git a/v7/src/runtime/hashtb.scm b/v7/src/runtime/hashtb.scm index 25ce6e060..2924b9e20 100644 --- a/v7/src/runtime/hashtb.scm +++ b/v7/src/runtime/hashtb.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: hashtb.scm,v 1.32 2005/01/23 17:53:05 cph Exp $ +$Id: hashtb.scm,v 1.33 2005/09/29 19:15:54 cph Exp $ Copyright 1990,1991,1993,1994,1995,2003 Massachusetts Institute of Technology Copyright 2004,2005 Massachusetts Institute of Technology @@ -225,7 +225,13 @@ USA. (define (hash-table/count table) (guarantee-hash-table table 'HASH-TABLE/COUNT) - (table-count table)) + (let loop () + (let ((count (table-count table))) + (if (table-needs-rehash? table) + (begin + (rehash-table! table) + (loop)) + count)))) (define (hash-table/size table) (guarantee-hash-table table 'HASH-TABLE/SIZE)