mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Minor evaluator tweaks
* libguile/eval.c (eval): Remove unused variable. * libguile/memoize.c (unmemoize): Fix unmemoization. * module/ice-9/eval.scm: Attempt to speed up common box-ref cases.
This commit is contained in:
parent
e6a42e6765
commit
5bfc0653d6
3 changed files with 23 additions and 7 deletions
|
@ -413,7 +413,7 @@ eval (SCM x, SCM env)
|
|||
return mx;
|
||||
else
|
||||
{
|
||||
SCM mod, var;
|
||||
SCM var;
|
||||
|
||||
var = scm_sys_resolve_variable (mx, env_tail (env));
|
||||
scm_set_cdr_x (x, var);
|
||||
|
|
|
@ -750,10 +750,15 @@ unmemoize (const SCM expr)
|
|||
unmemoize (CAR (args)),
|
||||
unmemoize (CDR (args)));
|
||||
case SCM_M_RESOLVE:
|
||||
return (SCM_VARIABLEP (args) || scm_is_symbol (args)) ? args
|
||||
: scm_list_3 (scm_is_true (CDDR (args)) ? scm_sym_at : scm_sym_atat,
|
||||
scm_i_finite_list_copy (CAR (args)),
|
||||
CADR (args));
|
||||
if (SCM_VARIABLEP (args))
|
||||
return args;
|
||||
else if (scm_is_symbol (CDR (args)))
|
||||
return CDR (args);
|
||||
else
|
||||
return scm_list_3
|
||||
(scm_is_true (CDDDR (args)) ? scm_sym_at : scm_sym_atat,
|
||||
scm_i_finite_list_copy (CADR (args)),
|
||||
CADDR (args));
|
||||
case SCM_M_CALL_WITH_PROMPT:
|
||||
return scm_list_4 (scm_from_latin1_symbol ("call-with-prompt"),
|
||||
unmemoize (CAR (args)),
|
||||
|
|
|
@ -279,9 +279,11 @@
|
|||
;; we compile `case' effectively, this situation will improve.
|
||||
(define-syntax mx-match
|
||||
(lambda (x)
|
||||
(syntax-case x (quote)
|
||||
(syntax-case x (quote else)
|
||||
((_ mx data tag)
|
||||
#'(error "what" mx))
|
||||
((_ mx data tag (else body))
|
||||
#'body)
|
||||
((_ mx data tag (('type pat) body) c* ...)
|
||||
#`(if (eqv? tag #,(or (memoized-typecode (syntax->datum #'type))
|
||||
(error "not a typecode" #'type)))
|
||||
|
@ -464,7 +466,16 @@
|
|||
(call eval proc nargs args env)))
|
||||
|
||||
(('box-ref box)
|
||||
(variable-ref (eval box env)))
|
||||
(memoized-expression-case box
|
||||
;; Accelerate common cases.
|
||||
(('resolve var-or-loc)
|
||||
(if (variable? var-or-loc)
|
||||
(variable-ref var-or-loc)
|
||||
(variable-ref (eval box env))))
|
||||
(('lexical-ref (depth . width))
|
||||
(variable-ref (env-ref env depth width)))
|
||||
(else
|
||||
(variable-ref (eval box env)))))
|
||||
|
||||
(('resolve var-or-loc)
|
||||
(if (variable? var-or-loc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue