use specialize-procedure on predicate portion or or/c

This seems to give about a 10% speedup on this program:

 #lang racket/base
(require racket/contract/base)
(define f (contract
           (-> (or/c number? symbol?) any)
           (λ (x) 0)
           'pos 'neg))

(time
 (for ([_ (in-range 1000000)])
   (f 'x) (f 'x) (f 'x) (f 'x)))
This commit is contained in:
Robby Findler 2015-12-25 14:12:36 -06:00
parent 0840fcd6c8
commit 7708b2056a

View File

@ -70,7 +70,8 @@
[(null? rst) fst-pred]
[else
(let ([r (loop (car rst) (cdr rst))])
(λ (x) (or (fst-pred x) (r x))))])))]))
(procedure-specialize
(λ (x) (or (fst-pred x) (r x)))))])))]))
(define (single-or/c-late-neg-projection ctc)
(define c-proj (get/build-late-neg-projection (single-or/c-ho-ctc ctc)))