Cut down bootstrap time by 10% by caching the values of scheme-stx.

Macroexpansion time is reduced by 25%.
This commit is contained in:
Abdulaziz Ghuloum 2008-03-12 18:12:57 -04:00
parent 1943212436
commit a3f6e3e039
2 changed files with 19 additions and 12 deletions

View File

@ -1 +1 @@
1411
1412

View File

@ -811,19 +811,26 @@
;;; (psyntax system $all) library, it creates a fresh identifier
;;; that maps only the symbol to its label in that library.
;;; Symbols not in that library become fresh.
(define scheme-stx-hashtable (make-eq-hashtable))
(define scheme-stx
(lambda (sym)
(let ((subst
(library-subst
(find-library-by-name '(psyntax system $all)))))
(cond
((assq sym subst) =>
(lambda (x)
(let ((name (car x)) (label (cdr x)))
(add-subst
(make-rib (list name) (list top-mark*) (list label) #f)
(mkstx sym top-mark* '() '())))))
(else (mkstx sym top-mark* '() '()))))))
(or (hashtable-ref scheme-stx-hashtable sym #f)
(let* ((subst
(library-subst
(find-library-by-name '(psyntax system $all))))
(stx (mkstx sym top-mark* '() '()))
(stx
(cond
((assq sym subst) =>
(lambda (x)
(let ((name (car x)) (label (cdr x)))
(add-subst
(make-rib (list name)
(list top-mark*) (list label) #f)
stx))))
(else stx))))
(hashtable-set! scheme-stx-hashtable sym stx)
stx))))
;;; macros
(define lexical-var car)