0.8.16.27:
authorWilliam Harold Newman <william.newman@airmail.net>
Tue, 2 Nov 2004 16:53:10 +0000 (16:53 +0000)
committerWilliam Harold Newman <william.newman@airmail.net>
Tue, 2 Nov 2004 16:53:10 +0000 (16:53 +0000)
made SXHASH values for CLOS instances be well-distributed

src/pcl/low.lisp
version.lisp-expr

index ea468f4..021c50e 100644 (file)
         nil)))
 \f
 ;;;; support for useful hashing of PCL instances
-(let ((hash-code 0))
-  (declare (fixnum hash-code))
-  (defun get-instance-hash-code ()
-    (if (< hash-code most-positive-fixnum)
-       (incf hash-code)
-       (setq hash-code 0))))
+
+(defvar *instance-hash-code-random-state* (make-random-state))
+(defun get-instance-hash-code ()
+  ;; ANSI SXHASH wants us to make a good-faith effort to produce
+  ;; hash-codes that are well distributed within the range of
+  ;; non-negative fixnums, and this RANDOM operation does that, unlike
+  ;; the sbcl<=0.8.16 implementation of this operation as
+  ;; (INCF COUNTER).
+  ;;
+  ;; Hopefully there was no virtue to the old counter implementation
+  ;; that I am insufficiently insightful to insee. -- WHN 2004-10-28
+  (random most-positive-fixnum
+         *instance-hash-code-random-state*))
 
 (defun sb-impl::sxhash-instance (x)
   (cond
index c9cbb67..bb81a17 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.16.26"
+"0.8.16.27"