Only canonicalize non (symbol/fixnum/struct-type)s, since these are already unique
This commit is contained in:
parent
b1c773ddd4
commit
1724860be2
|
@ -8,16 +8,23 @@
|
||||||
(define sentinel (cons #f #f))
|
(define sentinel (cons #f #f))
|
||||||
|
|
||||||
(define (canonicalize val)
|
(define (canonicalize val)
|
||||||
(define b (hash-ref canonical-values
|
(cond
|
||||||
val
|
[(or (struct-type? val)
|
||||||
(lambda ()
|
(symbol? val)
|
||||||
(define new-b (make-weak-box val))
|
(fixnum? val))
|
||||||
(hash-set! canonical-values val new-b)
|
;; These values already have unique representations.
|
||||||
#f)))
|
val]
|
||||||
(if (not b)
|
[else
|
||||||
(canonicalize val)
|
(define b (hash-ref canonical-values
|
||||||
(let ((v (weak-box-value b sentinel)))
|
val
|
||||||
(if (eq? v sentinel) (canonicalize val) v))))
|
(lambda ()
|
||||||
|
(define new-b (make-weak-box val))
|
||||||
|
(hash-set! canonical-values val new-b)
|
||||||
|
#f)))
|
||||||
|
(if (not b)
|
||||||
|
(canonicalize val)
|
||||||
|
(let ((v (weak-box-value b sentinel)))
|
||||||
|
(if (eq? v sentinel) (canonicalize val) v)))]))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
|
|
Loading…
Reference in New Issue