0.8.7.48:
[sbcl.git] / src / code / target-hash-table.lisp
index 52f01c3..26d751e 100644 (file)
@@ -15,7 +15,7 @@
 ;;;; utilities
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
-  (defconstant max-hash most-positive-fixnum))
+  (defconstant max-hash sb!xc:most-positive-fixnum))
 
 (deftype hash ()
   `(integer 0 ,max-hash))
@@ -81,6 +81,7 @@
 ;;;; construction and simple accessors
 
 (defconstant +min-hash-table-size+ 16)
+(defconstant +min-hash-table-rehash-threshold+ (float 1/16 1.0))
 
 (defun make-hash-table (&key (test 'eql)
                             (size +min-hash-table-size+)
                      (min size
                           ;; SIZE is just a hint, so if the user asks
                           ;; for a SIZE which'd be too big for us to
-                          ;; easily implement, we bump it down.
-                          (floor array-dimension-limit 16))))
+                          ;; easily implement, we bump it down.
+                          (floor array-dimension-limit 1024))))
           (rehash-size (if (integerp rehash-size)
                            rehash-size
                            (float rehash-size 1.0)))
           ;; FIXME: Original REHASH-THRESHOLD default should be 1.0,
           ;; not 1, to make it easier for the compiler to avoid
           ;; boxing.
-          (rehash-threshold (float rehash-threshold 1.0))
+          (rehash-threshold (max +min-hash-table-rehash-threshold+
+                                 (float rehash-threshold 1.0)))
           (size+1 (1+ size))           ; The first element is not usable.
            ;; KLUDGE: The most natural way of expressing the below is
            ;; (round (/ (float size+1) rehash-threshold)), and indeed
                   :hash-vector (unless (eq test 'eq)
                                  (make-array size+1
                                              :element-type '(unsigned-byte 32)
+                                             ;; as explained by pmai on
+                                             ;; openprojects #lisp IRC
+                                             ;; 2002-07-30: #x80000000 is
+                                             ;; bigger than any possible nonEQ
+                                             ;; hash value, and thus indicates
+                                             ;; an empty slot; and EQ hash
+                                             ;; tables don't use
+                                             ;; HASH-TABLE-HASH-VECTOR
                                              :initial-element #x80000000)))))
       (declare (type index size+1 scaled-size length))
       ;; Set up the free list, all free. These lists are 0 terminated.