From 90f199a0813aa56cfca7cbbfc925782c88102994 Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Sat, 16 Jan 2016 15:51:23 -0800 Subject: [PATCH] Don't add table to rehash population until an entry is created. --- src/runtime/hashtb.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/runtime/hashtb.scm b/src/runtime/hashtb.scm index aa9a10485..27391c527 100644 --- a/src/runtime/hashtb.scm +++ b/src/runtime/hashtb.scm @@ -67,10 +67,17 @@ USA. buckets (primes prime-numbers-stream) (needs-rehash? #f) - (initial-size-in-effect? #f)) + (initial-size-in-effect? #f) + (record-address-hash-table? #f)) (define-guarantee hash-table "hash table") +(define-integrable (check-address-hash-table table) + (if (table-record-address-hash-table? table) + (begin + (record-address-hash-table! table) + (set-table-record-address-hash-table?! table #f)))) + (define-integrable (increment-table-count! table) (set-table-count! table (fix:+ (table-count table) 1))) @@ -107,7 +114,7 @@ USA. (set-table-initial-size-in-effect?! table #t))) (reset-table! table) (if (table-type-rehash-after-gc? type) - (record-address-hash-table! table)) + (set-table-record-address-hash-table?! table #t)) table))) (define (hash-table/type table) @@ -635,6 +642,7 @@ USA. (if q (set-cdr! q r) (vector-set! (table-buckets table) hash r))) + (check-address-hash-table table) (increment-table-count! table) (maybe-grow-table! table))))))) method:put!) @@ -664,6 +672,7 @@ USA. (if q (set-cdr! q r) (vector-set! (table-buckets table) hash r))) + (check-address-hash-table table) (increment-table-count! table) (maybe-grow-table! table))) datum))))) -- 2.25.1