![]() This commit improves the performance of or/c contracts with symbols (or other things that the contract system compares with eq?). For example, on the program below we halve the distance to just writing the contract directly as a predicate. ``` #lang racket/base (require racket/contract/base) (define c1 (or/c 'x 'y (integer-in 1 24))) (define (c2 x) (or (eq? x 'x) (eq? x 'y) (and (exact-integer? x) (<= 1 x 24)))) (define f1 (contract (-> c1 any) (λ (x) x) 'pos 'neg)) (define f2 (contract (-> c2 any) (λ (x) x) 'pos 'neg)) (define (try f) (time (for ([x (in-range 1000000)]) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10) (f 'x) (f 'y) (f 10)))) (try f1) (try f2) ``` with this commit: cpu time: 849 real time: 850 gc time: 39 cpu time: 615 real time: 616 gc time: 2 without this commit: cpu time: 1020 real time: 1021 gc time: 37 cpu time: 616 real time: 617 gc time: 2 |
||
---|---|---|
.. | ||
collects | ||
src | ||
.gitignore |