[Openmcl-devel] hash-table-hash-function
Chris Dean
ctdean at sokitomi.com
Tue Apr 21 11:39:28 PDT 2009
[Looks like my earlier message was scrubbed, so I'll repost.]
Is there an existing way to extract the hash-function from a hash-table?
Turns out that I need one to properly serialize some data structures.
In case there isn't one, I have a patch below to add a
hash-table-hash-function and put it in the CCL package.
Cheers,
Chris Dean
Index: lib/ccl-export-syms.lisp
===================================================================
--- lib/ccl-export-syms.lisp (revision 11952)
+++ lib/ccl-export-syms.lisp (working copy)
@@ -271,6 +271,8 @@
init-list-default
fset
+ hash-table-hash-function
+
; Files.
mac-default-directory
current-directory
Index: level-0/l0-hash.lisp
===================================================================
--- level-0/l0-hash.lisp (revision 11952)
+++ level-0/l0-hash.lisp (working copy)
@@ -576,6 +576,13 @@
(if (eql 0 f) #'eq #'eql)
f)))
+(defun hash-table-hash-function (hash)
+ "Return the hashing function HASH-TABLE was created with."
+ (let ((fn (nhash.keytransF (require-type hash 'hash-table))))
+ (if (fixnump fn)
+ nil
+ fn)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; nearly-lock-free hash tables
More information about the Openmcl-devel
mailing list