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:
parent
f7382b17c7
commit
da66d4d559
|
@ -168,17 +168,17 @@
|
||||||
#`[(#,(car x)) #,(cdr x)])
|
#`[(#,(car x)) #,(cdr x)])
|
||||||
alist)
|
alist)
|
||||||
[else #,else-exp])
|
[else #,else-exp])
|
||||||
#`(let ([tbl #,(make-hashX alist)])
|
(let ([tbl (make-hashX alist)])
|
||||||
#,(if (literal-expression? else-exp)
|
(if (literal-expression? else-exp)
|
||||||
#`(hash-ref tbl #,tmp-stx #,else-exp)
|
#`(hash-ref #,tbl #,tmp-stx (lambda () #,else-exp))
|
||||||
#`(or (hash-ref tbl #,tmp-stx #f)
|
#`(or (hash-ref #,tbl #,tmp-stx (lambda () #f))
|
||||||
#,else-exp)))))
|
#,else-exp)))))
|
||||||
|
|
||||||
(define (dispatch-symbol tmp-stx symbol-alist 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)
|
(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 (test-for-symbol tmp-stx alist)
|
||||||
(define (contains? pred)
|
(define (contains? pred)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user