Don't add table to rehash population until an entry is created.
authorJoe Marshall <jmarshall@alum.mit.edu>
Sat, 16 Jan 2016 23:51:23 +0000 (15:51 -0800)
committerJoe Marshall <jmarshall@alum.mit.edu>
Sat, 16 Jan 2016 23:51:23 +0000 (15:51 -0800)
src/runtime/hashtb.scm

index aa9a104855066131b4ff03ed4cd57b27c653f7e4..27391c527bc67202139341ed0eb4b592a657d6f6 100644 (file)
@@ -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)))))