X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-sxhash.lisp;h=5fb976226b61a9144c08d80930b759adad32b472;hb=073501ed49414d9638cb41c05fb80627529f796d;hp=7f6f7b309547c05cbb0942423bd0e8737bafe2db;hpb=de201aeb12169d0bd377eca4da6116c2797a66ad;p=sbcl.git diff --git a/src/code/target-sxhash.lisp b/src/code/target-sxhash.lisp index 7f6f7b3..5fb9762 100644 --- a/src/code/target-sxhash.lisp +++ b/src/code/target-sxhash.lisp @@ -99,7 +99,7 @@ ;;; (unless (string= (gethash hash ht) string) ;;; (format t "collision: ~S ~S~%" string (gethash hash ht))) ;;; (setf (gethash hash ht) string)))) -;;; (format t "final count=~D~%" (hash-table-count ht))) +;;; (format t "final count=~W~%" (hash-table-count ht))) (defun %sxhash-simple-string (x) (declare (optimize speed)) @@ -117,7 +117,7 @@ (defun sxhash (x) (labels ((sxhash-number (x) (etypecase x - (fixnum (sxhash x)) ; through DEFTRANSFORM + (fixnum (sxhash x)) ; through DEFTRANSFORM (integer (sb!bignum:sxhash-bignum x)) (single-float (sxhash x)) ; through DEFTRANSFORM (double-float (sxhash x)) ; through DEFTRANSFORM @@ -145,9 +145,15 @@ (logxor 422371266 (sxhash ; through DEFTRANSFORM (class-name (layout-class (%instance-layout x))))) + ;; Nice though it might be to return a nontrivial + ;; hash value for other instances (especially + ;; STANDARD-OBJECTs) there seems to be no good way + ;; to do so. We can't even do the CLASS-NAME trick + ;; (as used above for STRUCTURE-OBJECT) because + ;; then CHANGE-CLASS would cause SXHASH values to + ;; change, ouch! -- WHN recording wisdom of CSR 309518995)) (symbol (sxhash x)) ; through DEFTRANSFORM - (number (sxhash-number x)) (array (typecase x (simple-string (sxhash x)) ; through DEFTRANSFORM @@ -161,6 +167,8 @@ (character (logxor 72185131 (sxhash (char-code x)))) ; through DEFTRANSFORM + ;; general, inefficient case of NUMBER + (number (sxhash-number x)) (t 42)))) (sxhash-recurse x)))