fix calculation for hash code of a hash table
This commit is contained in:
parent
87652cd32e
commit
039f9c10f3
|
@ -2521,6 +2521,16 @@
|
||||||
(list? (list* 1 2 p))
|
(list? (list* 1 2 p))
|
||||||
(test 1 hash-ref ht p #f))
|
(test 1 hash-ref ht p #f))
|
||||||
|
|
||||||
|
;; Check that hash-table cycles don't lead to an
|
||||||
|
;; explosion in the time to compute a hash code.
|
||||||
|
(let ()
|
||||||
|
(define ht (make-hash))
|
||||||
|
(hash-set! ht 'a ht)
|
||||||
|
(hash-set! ht 'b ht)
|
||||||
|
(eq-hash-code ht)
|
||||||
|
(equal-hash-code ht)
|
||||||
|
(equal-secondary-hash-code ht))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Misc
|
;; Misc
|
||||||
|
|
||||||
|
|
|
@ -1264,7 +1264,7 @@ static uintptr_t equal_hash_key(Scheme_Object *o, uintptr_t k, Hash_Info *hi)
|
||||||
# include "mzhashchk.inc"
|
# include "mzhashchk.inc"
|
||||||
|
|
||||||
k = (k << 1) + 3;
|
k = (k << 1) + 3;
|
||||||
hi->depth += 2;
|
hi->depth *= 2; /* mult to counteract potential explosion due to old_depth reset */
|
||||||
old_depth = hi->depth;
|
old_depth = hi->depth;
|
||||||
|
|
||||||
keys = ht->keys;
|
keys = ht->keys;
|
||||||
|
@ -1676,7 +1676,7 @@ static uintptr_t equal_hash_key2(Scheme_Object *o, Hash_Info *hi)
|
||||||
|
|
||||||
# include "mzhashchk.inc"
|
# include "mzhashchk.inc"
|
||||||
|
|
||||||
hi->depth += 2;
|
hi->depth *= 2; /* mult to counteract potential explosion due to old_depth reset */
|
||||||
old_depth = hi->depth;
|
old_depth = hi->depth;
|
||||||
|
|
||||||
keys = ht->keys;
|
keys = ht->keys;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user