Avoid generating definitions for contracts that are identifiers.

This reduces the number of pointless definitions, and re-enables
some contract system optimizations.
This commit is contained in:
Sam Tobin-Hochstadt 2016-01-02 11:46:51 -05:00
parent a0d6ed954d
commit 84d26b91ca
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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))