Only canonicalize non (symbol/fixnum/struct-type)s, since these are already unique

This commit is contained in:
Tony Garnock-Jones 2016-03-13 10:39:02 +00:00
parent b1c773ddd4
commit 1724860be2
1 changed files with 17 additions and 10 deletions

View File

@ -8,6 +8,13 @@
(define sentinel (cons #f #f))
(define (canonicalize val)
(cond
[(or (struct-type? val)
(symbol? val)
(fixnum? val))
;; These values already have unique representations.
val]
[else
(define b (hash-ref canonical-values
val
(lambda ()
@ -17,7 +24,7 @@
(if (not b)
(canonicalize val)
(let ((v (weak-box-value b sentinel)))
(if (eq? v sentinel) (canonicalize val) v))))
(if (eq? v sentinel) (canonicalize val) v)))]))
(module+ test
(require rackunit)