Speed up free-vars checking for primitives

We know prims are only symbols, so instead of checking for primitives in the top-level cond (which is expensive) we check for it as a sub-condition off of the (ref?) condition. This lets us avoid a call to memq unless we already are inspecting a symbol.
This commit is contained in:
Justin Ethier 2018-12-18 22:00:19 -05:00
parent dd9b612be4
commit 70b27ccd22

View file

@ -705,12 +705,15 @@ if (acc) {
(difference (reduce union (map search (ast:lambda-body exp)) '()) (difference (reduce union (map search (ast:lambda-body exp)) '())
(ast:lambda-formals->list exp))) (ast:lambda-formals->list exp)))
((const? exp) '()) ((const? exp) '())
((prim? exp) '())
((quote? exp) '()) ((quote? exp) '())
((ref? exp) ((ref? exp)
(cond
((prim? exp)
'())
(else
(if (member exp let-vars) (if (member exp let-vars)
'() '()
(if bound-only? '() (list exp)))) (if bound-only? '() (list exp))))))
((lambda? exp) ((lambda? exp)
(difference (reduce union (map search (lambda->exp exp)) '()) (difference (reduce union (map search (lambda->exp exp)) '())
(lambda-formals->list exp))) (lambda-formals->list exp)))