From: Andy Wingo Date: Thu, 12 Mar 2015 13:48:03 +0000 (+0100) Subject: Only lazily compile where profitable X-Git-Url: https://git.hcoop.net/bpt/guile.git/commitdiff_plain/fe7ecee8204fa79bfebcc925b82e1e670ed34cea Only lazily compile where profitable * module/ice-9/eval.scm (primitive-eval): Only lazily compile box-ref on toplevel variables; otherwise compile eagerly to avoid the indirection. --- diff --git a/module/ice-9/eval.scm b/module/ice-9/eval.scm index f5bcc16b4..3b68f07ae 100644 --- a/module/ice-9/eval.scm +++ b/module/ice-9/eval.scm @@ -213,11 +213,12 @@ '() (cons ((car args) env) (lp (cdr args))))))))))))) - (define (compile-box-ref cenv box) + (define (compile-box-ref box) (match box ((,(typecode resolve) . loc) - (let ((var (%resolve-variable loc (env-toplevel cenv)))) - (lambda (env) (variable-ref var)))) + (lazy (cenv) + (let ((var (%resolve-variable loc (env-toplevel cenv)))) + (lambda (env) (variable-ref var))))) ((,(typecode lexical-ref) depth . width) (lambda (env) (variable-ref (env-ref env depth width)))) @@ -655,7 +656,7 @@ (compile-call f args)) ((,(typecode box-ref) . box) - (lazy (env) (compile-box-ref env box))) + (compile-box-ref box)) ((,(typecode resolve) . loc) (lazy (env) (compile-resolve env loc)))