From 84d26b91cae4150c63cb91b6dd5d0ea31de03454 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Sat, 2 Jan 2016 11:46:51 -0500 Subject: [PATCH] Avoid generating definitions for contracts that are identifiers. This reduces the number of pointless definitions, and re-enables some contract system optimizations. --- .../typed-racket/private/type-contract.rkt | 13 ++++++++----- .../typed-racket/static-contracts/instantiate.rkt | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/typed-racket-lib/typed-racket/private/type-contract.rkt b/typed-racket-lib/typed-racket/private/type-contract.rkt index c734ccff..cd7a6e85 100644 --- a/typed-racket-lib/typed-racket/private/type-contract.rkt +++ b/typed-racket-lib/typed-racket/private/type-contract.rkt @@ -145,11 +145,14 @@ (and (identifier? ctc-stx) (let ([match? (assoc ctc-stx (hash-values cache) free-identifier=?)]) (and match? - ;; ->* are handled specially by the contract system - (let ([sexp (syntax-e (cdr match?))]) - (and (pair? sexp) - (or (free-identifier=? (car sexp) #'->) - (free-identifier=? (car sexp) #'->*)))) + (or + ;; no need to generate an extra def for things that are already identifiers + (identifier? match?) + ;; ->* are handled specially by the contract system + (let ([sexp (syntax-e (cdr match?))]) + (and (pair? sexp) + (or (free-identifier=? (car sexp) #'->) + (free-identifier=? (car sexp) #'->*))))) (cdr match?))))) ;; The below requires are needed since they provide identifiers that diff --git a/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt b/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt index bca74d72..9ac77dfa 100644 --- a/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt +++ b/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt @@ -144,7 +144,7 @@ (make-contract sc)] [else (define ctc (make-contract sc)) - (cond [cache + (cond [(and (not (identifier? ctc)) cache) (define fresh-id (generate-temporary)) (hash-set! cache sc (cons fresh-id ctc)) (set! sc-queue (cons sc sc-queue))