[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/02: Eval speedup for lexical-ref
From: |
Andy Wingo |
Subject: |
[Guile-commits] 01/02: Eval speedup for lexical-ref |
Date: |
Wed, 11 Nov 2015 14:43:22 +0000 |
wingo pushed a commit to branch master
in repository guile.
commit 25738ec35d28437f5703147bc43cf0d45afff964
Author: Andy Wingo <address@hidden>
Date: Wed Nov 11 14:51:19 2015 +0100
Eval speedup for lexical-ref
* module/ice-9/eval.scm (primitive-eval): Specialize lexical-ref for
depths 0, 1, and 2. Speeds up this test by around 13%:
(primitive-eval '(let lp ((n 0)) (when (< n #e1e7) (lp (1+ n)))))
---
module/ice-9/eval.scm | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/module/ice-9/eval.scm b/module/ice-9/eval.scm
index 3b68f07..a2bab20 100644
--- a/module/ice-9/eval.scm
+++ b/module/ice-9/eval.scm
@@ -119,8 +119,11 @@
(proc arg ...))))
(define (compile-lexical-ref depth width)
- (lambda (env)
- (env-ref env depth width)))
+ (case depth
+ ((0) (lambda (env) (env-ref env 0 width)))
+ ((1) (lambda (env) (env-ref env 1 width)))
+ ((2) (lambda (env) (env-ref env 2 width)))
+ (else (lambda (env) (env-ref env depth width)))))
(define (primitive=? name loc module var)
"Return true if VAR is the same as the primitive bound to NAME."