From 70b27ccd22e481307d45f4ab0c1ee16c3bef8df7 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 18 Dec 2018 22:00:19 -0500 Subject: [PATCH] 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. --- scheme/cyclone/transforms.sld | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scheme/cyclone/transforms.sld b/scheme/cyclone/transforms.sld index e0062cd4..1289904d 100644 --- a/scheme/cyclone/transforms.sld +++ b/scheme/cyclone/transforms.sld @@ -705,12 +705,15 @@ if (acc) { (difference (reduce union (map search (ast:lambda-body exp)) '()) (ast:lambda-formals->list exp))) ((const? exp) '()) - ((prim? exp) '()) ((quote? exp) '()) ((ref? exp) - (if (member exp let-vars) - '() - (if bound-only? '() (list exp)))) + (cond + ((prim? exp) + '()) + (else + (if (member exp let-vars) + '() + (if bound-only? '() (list exp)))))) ((lambda? exp) (difference (reduce union (map search (lambda->exp exp)) '()) (lambda-formals->list exp)))