Skip to content
Snippets Groups Projects
Commit 4c0856d0 authored by ram's avatar ram
Browse files

add init-form arg to define-hash-cache.

parent 5a76e9e7
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/extensions.lisp,v 1.14 1992/12/31 13:36:23 ram Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/extensions.lisp,v 1.14.1.1 1993/01/28 13:59:37 ram Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -396,7 +396,11 @@ ...@@ -396,7 +396,11 @@
;;; DEFINE-HASH-CACHE -- Public ;;; DEFINE-HASH-CACHE -- Public
;;; ;;;
;;; :INIT-FORM passed as COLD-LOAD-INIT in type system definitions so that
;;; caches can be created before top-level forms run.
;;;
(defmacro define-hash-cache (name args &key hash-function hash-bits default (defmacro define-hash-cache (name args &key hash-function hash-bits default
(init-form 'progn)
(values 1)) (values 1))
"DEFINE-HASH-CACHE Name ({(Arg-Name Test-Function)}*) {Key Value}* "DEFINE-HASH-CACHE Name ({(Arg-Name Test-Function)}*) {Key Value}*
Define a hash cache that associates some number of argument values to a Define a hash cache that associates some number of argument values to a
...@@ -433,7 +437,11 @@ ...@@ -433,7 +437,11 @@
between 0 and (1- (expt 2 <hash-bits>)). between 0 and (1- (expt 2 <hash-bits>)).
:VALUES <n> :VALUES <n>
The number of values cached." The number of values cached.
:INIT-FORM <name>
The DEFVAR for creating the cache is enclosed in a form with the
specified name. Default PROGN."
(let* ((var-name (symbolicate "*" name "-CACHE-VECTOR*")) (let* ((var-name (symbolicate "*" name "-CACHE-VECTOR*"))
(nargs (length args)) (nargs (length args))
...@@ -533,7 +541,10 @@ ...@@ -533,7 +541,10 @@
(forms `(,fun-name))) (forms `(,fun-name)))
`(progn `(progn
(defvar ,var-name (make-array ,total-size)) (defvar ,var-name)
(,init-form
(unless (boundp ,var-name)
(setq ,var-name (make-array ,total-size))))
(proclaim '(type (simple-vector ,total-size) ,var-name)) (proclaim '(type (simple-vector ,total-size) ,var-name))
(proclaim '(inline ,@(inlines))) (proclaim '(inline ,@(inlines)))
,@(forms) ,@(forms)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment