adjust `case' expansion to work with Typed Racket

Relies on the new ad hoc optimization of `hash-ref' to preserve
performance.
This commit is contained in:
Matthew Flatt 2012-07-23 21:40:39 -05:00
parent f7382b17c7
commit da66d4d559

View File

@ -168,17 +168,17 @@
#`[(#,(car x)) #,(cdr x)])
alist)
[else #,else-exp])
#`(let ([tbl #,(make-hashX alist)])
#,(if (literal-expression? else-exp)
#`(hash-ref tbl #,tmp-stx #,else-exp)
#`(or (hash-ref tbl #,tmp-stx #f)
#,else-exp)))))
(let ([tbl (make-hashX alist)])
(if (literal-expression? else-exp)
#`(hash-ref #,tbl #,tmp-stx (lambda () #,else-exp))
#`(or (hash-ref #,tbl #,tmp-stx (lambda () #f))
#,else-exp)))))
(define (dispatch-symbol tmp-stx symbol-alist else-exp)
(dispatch-hashable tmp-stx symbol-alist make-hasheq else-exp))
(dispatch-hashable tmp-stx symbol-alist make-immutable-hasheq else-exp))
(define (dispatch-other tmp-stx other-alist else-exp)
(dispatch-hashable tmp-stx other-alist make-hasheqv else-exp))
(dispatch-hashable tmp-stx other-alist make-immutable-hasheqv else-exp))
(define (test-for-symbol tmp-stx alist)
(define (contains? pred)